private List <VsError> GetErrorList_VS2015() { var vsErrorList = new List <VsError>(); var errorList = this.GetService(typeof(SVsErrorList)) as IVsTaskList2; if (errorList != null) { IVsEnumTaskItems enumerator; errorList.EnumSelectedItems(out enumerator); var arr = new IVsTaskItem[1]; while (enumerator.Next(1, arr, null) == 0) { string description; arr[0].get_Text(out description); string fileName; arr[0].Document(out fileName); int lineNumber; arr[0].Line(out lineNumber); vsErrorList.Add(new VsError() { Description = description, FileName = fileName, Line = lineNumber, ErrorItem = arr[0], }); } } return(vsErrorList); }
List <Task> GetSelectedTasks() { var result = new List <Task>(); int hr = VSConstants.S_OK; var taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; if (taskList == null) { Debug.Fail("Failed to get SVsTaskList service."); return(result); } IVsEnumTaskItems enumerator = null; hr = taskList.EnumSelectedItems(out enumerator); Debug.Assert(hr == VSConstants.S_OK, "EnumSelectedItems did not return S_OK."); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { Task task = items[0] as Task; if (task != null) { result.Add(task); } } return(result); }
public TaskItemInfo(IVsTaskItem taskItem) { ErrorHandler.ThrowOnFailure(taskItem.Document(out Document)); ErrorHandler.ThrowOnFailure(taskItem.get_Text(out Message)); ErrorHandler.ThrowOnFailure(taskItem.Line(out Line)); ErrorHandler.ThrowOnFailure(taskItem.Column(out Column)); var priority = new VSTASKPRIORITY[1]; ErrorHandler.ThrowOnFailure(taskItem.get_Priority(priority)); Priority = priority[0]; var category = new VSTASKCATEGORY[1]; ErrorHandler.ThrowOnFailure(taskItem.Category(category)); Category = category[0]; var errorItem = taskItem as IVsErrorItem; if (errorItem != null) { uint errorCategory; try { ErrorHandler.ThrowOnFailure(errorItem.GetCategory(out errorCategory)); ErrorCategory = (__VSERRORCATEGORY)errorCategory; } catch (NotImplementedException) { ErrorCategory = null; } } else { ErrorCategory = null; } }
public TaskItemInfo(IVsTaskItem taskItem) { ErrorHandler.ThrowOnFailure(taskItem.Document(out Document)); ErrorHandler.ThrowOnFailure(taskItem.get_Text(out Message)); ErrorHandler.ThrowOnFailure(taskItem.Line(out Line)); ErrorHandler.ThrowOnFailure(taskItem.Column(out Column)); // TODO: get_Priority and Category are not implemented by VS LSC (returns E_FAIL) Priority = VSTASKPRIORITY.TP_HIGH; Category = VSTASKCATEGORY.CAT_CODESENSE; ErrorCategory = null; //var priority = new VSTASKPRIORITY[1]; //ErrorHandler.ThrowOnFailure(taskItem.get_Priority(priority)); //Priority = priority[0]; //var category = new VSTASKCATEGORY[1]; //ErrorHandler.ThrowOnFailure(taskItem.Category(category)); //Category = category[0]; //var errorItem = taskItem as IVsErrorItem; //if (errorItem != null) { // uint errorCategory; // try { // ErrorHandler.ThrowOnFailure(errorItem.GetCategory(out errorCategory)); // ErrorCategory = (__VSERRORCATEGORY)errorCategory; // } catch (NotImplementedException) { // ErrorCategory = null; // } //} else { // ErrorCategory = null; //} }
int IVsEnumTaskItems.Skip(uint celt) { IVsTaskItem[] xItems = new IVsTaskItem[celt]; uint[] fetched = new uint[] { 0 }; return((this as IVsEnumTaskItems).Next(celt, xItems, fetched)); }
public List <IVsTaskItem> WaitForErrorListItems(int expectedCount) { var errorList = GetService <IVsTaskList>(typeof(SVsErrorList)); var allItems = new List <IVsTaskItem>(); if (expectedCount == 0) { // Allow time for errors to appear. Otherwise when we expect 0 // errors we will get a false pass. System.Threading.Thread.Sleep(5000); } for (int retries = 10; retries > 0; --retries) { allItems.Clear(); IVsEnumTaskItems items; ErrorHandler.ThrowOnFailure(errorList.EnumTaskItems(out items)); IVsTaskItem[] taskItems = new IVsTaskItem[1]; uint[] itemCnt = new uint[1]; while (ErrorHandler.Succeeded(items.Next(1, taskItems, itemCnt)) && itemCnt[0] == 1) { allItems.Add(taskItems[0]); } if (allItems.Count >= expectedCount) { break; } // give time for errors to process... System.Threading.Thread.Sleep(1000); } return(allItems); }
protected IVsTask RefreshOrAddTasks(IVsTaskItem[] newTasks) { if (newTasks.Length <= 0) { return null; } // Don't update more than this many items at a time to avoid perf problems const int MaxTasksToAddInOneCall = 50; if (newTasks.Length <= MaxTasksToAddInOneCall) { return _tasklist.RefreshOrAddTasksAsync(_providerCookie, newTasks.Length, newTasks); } else { var arraySubset = new IVsTaskItem[MaxTasksToAddInOneCall]; IVsTask lastTask = null; for (int i = 0; i < newTasks.Length; i += MaxTasksToAddInOneCall) { var subsetSize = Math.Min(MaxTasksToAddInOneCall, newTasks.Length - i); if (subsetSize > 0) { Array.Copy(newTasks, i, arraySubset, 0, subsetSize); lastTask = _tasklist.RefreshOrAddTasksAsync(_providerCookie, subsetSize, arraySubset); } } // we only need last task. VS already serialize request internally return lastTask; } }
protected IVsTask RefreshOrAddTasks(IVsTaskItem[] newTasks) { if (newTasks.Length <= 0) { return(null); } // Don't update more than this many items at a time to avoid perf problems const int MaxTasksToAddInOneCall = 50; if (newTasks.Length <= MaxTasksToAddInOneCall) { return(_tasklist.RefreshOrAddTasksAsync(_providerCookie, newTasks.Length, newTasks)); } else { var arraySubset = new IVsTaskItem[MaxTasksToAddInOneCall]; IVsTask lastTask = null; for (int i = 0; i < newTasks.Length; i += MaxTasksToAddInOneCall) { var subsetSize = Math.Min(MaxTasksToAddInOneCall, newTasks.Length - i); if (subsetSize > 0) { Array.Copy(newTasks, i, arraySubset, 0, subsetSize); lastTask = _tasklist.RefreshOrAddTasksAsync(_providerCookie, subsetSize, arraySubset); } } // we only need last task. VS already serialize request internally return(lastTask); } }
private static List <IVsTaskItem> GetErrorListItems(IVsErrorList errorList, int expectedItems) { List <IVsTaskItem> allItems = new List <IVsTaskItem>(); for (int i = 0; i < 10; i++) { allItems.Clear(); IVsEnumTaskItems items; ErrorHandler.ThrowOnFailure(((IVsTaskList)errorList).EnumTaskItems(out items)); IVsTaskItem[] taskItems = new IVsTaskItem[1]; uint[] itemCnt = new uint[1]; while (ErrorHandler.Succeeded(items.Next(1, taskItems, itemCnt)) && itemCnt[0] == 1) { allItems.Add(taskItems[0]); } if (allItems.Count == expectedItems) { break; } // give time for errors to process... System.Threading.Thread.Sleep(1000); } return(allItems); }
/// <summary> /// Skips a specified number of items /// </summary> /// <param name="celt">The number of items to skip.</param> /// <returns>S_OK if the requested number of items was skipped; S_FALSE if <c>celt</c> is larger than the number of available items; E_INVALIDARG if <c>celt</c> is less than zero.</returns> /// <remarks> /// This method returns failure codes instead of throwing exceptions because it is intended to be called from native code. /// If the task provider's IsShowingIgnoredInstances property is false, ignored instances will not be counted. /// </remarks> public int Skip(uint celt) { IVsTaskItem[] items = new IVsTaskItem[celt]; uint[] fetched = new uint[] { 0 }; return(Next(celt, items, fetched)); }
public static string GetProject(this IVsTaskItem item) { var errorItem = item as IVsErrorItem; ErrorHandler.ThrowOnFailure(errorItem.GetHierarchy(out var hierarchy)); ErrorHandler.ThrowOnFailure(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_Name, out var name)); return((string)name); }
private string ProcessString(IVsTaskItem[] arr, bool generalSearch) { string text; arr[0].get_Text(out text); if(generalSearch) text = Regex.Replace(text, "'.*'", "", RegexOptions.IgnoreCase); return text; }
public List <IVsTaskItem> WaitForTaskListItems(Type taskListService, int expectedCount, bool exactMatch = true) { Console.Write("Waiting for {0} items on {1} ... ", expectedCount, taskListService.Name); var errorList = GetService <IVsTaskList>(taskListService); var allItems = new List <IVsTaskItem>(); if (expectedCount == 0) { // Allow time for errors to appear. Otherwise when we expect 0 // errors we will get a false pass. System.Threading.Thread.Sleep(5000); } for (int retries = 20; retries > 0; --retries) { allItems.Clear(); IVsEnumTaskItems items; ErrorHandler.ThrowOnFailure(errorList.EnumTaskItems(out items)); IVsTaskItem[] taskItems = new IVsTaskItem[1]; uint[] itemCnt = new uint[1]; while (ErrorHandler.Succeeded(items.Next(1, taskItems, itemCnt)) && itemCnt[0] == 1) { allItems.Add(taskItems[0]); } if (expectedCount > 0 && allItems.Count >= expectedCount || allItems.Count == expectedCount) { break; } // give time for errors to process... System.Threading.Thread.Sleep(1000); } foreach (var item in allItems) { string text, document; if (ErrorHandler.Succeeded(item.Document(out document)) && ErrorHandler.Succeeded(item.get_Text(out text))) { Console.WriteLine("Task Item: {0} :: {1}", text, document); } else { Console.WriteLine("Task Item: <unknown>"); } } if (exactMatch) { Assert.AreEqual(expectedCount, allItems.Count); } return(allItems); }
public int Next(uint celt, IVsTaskItem[] rgelt, uint[] pceltFetched) { for (pceltFetched[0] = 0; celt > 0; --celt, ++pceltFetched[0]) { if (_next >= _items.Count) { return VSConstants.S_FALSE; } rgelt[pceltFetched[0]] = _items[_next++]; } return VSConstants.S_OK; }
/// <summary> /// Get error items from "Error List" window asynchronously. In case of error returns <c>null</c>. /// </summary> /// <param name="serviceProvider">The package Service Provider.</param> /// <returns/> internal static async Task <List <IVsTaskItem> > GetErrorListAsync(this Shell.IAsyncServiceProvider serviceProvider) { if (serviceProvider == null) { return(null); } await Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var errorService = await serviceProvider.GetServiceAsync <SVsErrorList, IVsTaskList>(); if (errorService == null) { return(null); } int result = VSConstants.S_OK; List <IVsTaskItem> taskItemsList = new List <IVsTaskItem>(capacity: 8); try { ErrorHandler.ThrowOnFailure(errorService.EnumTaskItems(out IVsEnumTaskItems errorItems)); if (errorItems == null) { return(null); } // Retrieve the task item text and check whether it is equal with one that supposed to be thrown. uint[] fetched = new uint[1]; do { IVsTaskItem[] taskItems = new IVsTaskItem[1]; result = errorItems.Next(1, taskItems, fetched); if (fetched[0] == 1 && taskItems[0] is IVsTaskItem2 taskItem) { taskItemsList.Add(taskItem); } }while (result == VSConstants.S_OK && fetched[0] == 1); } catch (System.Runtime.InteropServices.COMException e) { result = e.ErrorCode; } return(result == VSConstants.S_OK ? taskItemsList : null); }
/// <summary> /// The set selected. /// </summary> /// <param name="item"> /// The item. /// </param> /// <param name="selected"> /// The selected. /// </param> public void SetSelected(IVsTaskItem item, bool selected) { if (!selected) { this._selection.Remove(item); } else { if (!this._selection.Contains(item)) { this._selection.Add(item); } } }
static public List <IVsTaskItem> TasksFromEnumerator(IVsEnumTaskItems enumerator) { List <IVsTaskItem> result = new List <IVsTaskItem>(); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { result.Add(items[0]); } return(result); }
public Threading.Task SendErrorDetails(IVsTaskList errorList) { Threading.Task processTaskListTask = new System.Threading.Tasks.Task(() => { _processorStopwatch.Start(); IVsEnumTaskItems taskEnum = null; IVsTaskItem[] oneItem = new IVsTaskItem[1]; if (errorList != null) { errorList.EnumTaskItems(out taskEnum); if (taskEnum != null) { int maxItems = 10000; Int32.TryParse(Properties.Resources.MaxErrorsToProcess, out maxItems); taskEnum.Next(1, oneItem, null); for (int i = 0; (i < maxItems) && (oneItem[0] != null); ++i) { ProcessTaskListItem(oneItem[0]); taskEnum.Next(1, oneItem, null); } // send all events in case the Visual Studio instance is closed or solution unloaded BuildTelemetryClient.FlushEvents(); } } _processorStopwatch.Stop(); Dictionary <string, string> perfProperties = new Dictionary <string, string>(); perfProperties.Add("BuildId", _currentBuildGuid.ToString()); perfProperties.Add("ProjectId", _firstIslandwoodProjectGuid.ToString()); Dictionary <string, double> perfMetrics = new Dictionary <string, double>(); perfMetrics.Add("ProcessTasks", _processorStopwatch.ElapsedMilliseconds); BuildTelemetryClient.TrackEvent("IslandwoodBuildMonitorPerformance", perfProperties, perfMetrics); // reset state in case projects/solutions are unloaded before next build _firstIslandwoodProjectGuid = Guid.Empty; }); processTaskListTask.Start(); return(processTaskListTask); }
private void SearchErrorOn(object sender, EventArgs e) { var errorList = this.ServiceProvider.GetService(typeof(SVsErrorList)) as IVsTaskList2; IVsEnumTaskItems enumerator; errorList.EnumSelectedItems(out enumerator); var package = this.package as SearchOnPackage; var arr = new IVsTaskItem[1]; while (enumerator.Next(1, arr, null) == 0) { string error = ProcessString(arr, package.SettingsManager.GeneralSearch); var query = package.SettingsManager.CurrentEngine.GenerateQuery(error); BrowserFactory.Create(package.SettingsManager.InternalBrowser).Run(query); } }
private void SearchErrorOn(object sender, EventArgs e) { var errorList = this.ServiceProvider.GetService(typeof(SVsErrorList)) as IVsTaskList2; IVsEnumTaskItems enumerator; errorList.EnumSelectedItems(out enumerator); var package = this.package as SearchOnPackage; var arr = new IVsTaskItem[1]; while (enumerator.Next(1, arr, null) == 0) { string text; arr[0].get_Text(out text); package.EngineManager.CurrentEngine.Search(text); } }
public static IEnumerable <IVsTaskItem> AsEnumerable(this IVsEnumTaskItems items) { var item = new IVsTaskItem[1]; while (true) { var hr = items.Next(1, item, null); ErrorHandler.ThrowOnFailure(hr); if (hr == VSConstants.S_FALSE) { break; } yield return(item[0]); } }
private void ProcessTaskListItem(IVsTaskItem taskListItem) { IVsErrorItem errorTaskItem = taskListItem as IVsErrorItem; if (errorTaskItem != null) { uint errorCategory = 255; errorTaskItem.GetCategory(out errorCategory); // is this task an error from an Islandwood project if (errorCategory == (uint)TaskErrorCategory.Error || errorCategory == (uint)TaskErrorCategory.Warning) { string sourceFile = string.Empty; taskListItem.Document(out sourceFile); if (string.IsNullOrEmpty(sourceFile) == false && (sourceFile.EndsWith(".m") || sourceFile.EndsWith(".mm") || sourceFile.EndsWith(".h"))) { Dictionary <string, string> errorDetails = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); errorDetails.Add("BuildId", _currentBuildGuid.ToString()); Guid errorProjectGuid = _firstIslandwoodProjectGuid; IVsHierarchy errorTaskItemHierarchy = null; if (errorTaskItem.GetHierarchy(out errorTaskItemHierarchy) == 0 && errorTaskItemHierarchy != null) { _solution.GetGuidOfProject(errorTaskItemHierarchy, out errorProjectGuid); } errorDetails.Add("ProjectId", errorProjectGuid.ToString()); string errorCategoryText = errorCategory == 0 ? TaskErrorCategory.Error.ToString() : TaskErrorCategory.Warning.ToString(); errorDetails.Add("Category", errorCategoryText); string rawErrorText = string.Empty; taskListItem.get_Text(out rawErrorText); errorDetails.Add("Description", ParseAndScrubErrorMessage(rawErrorText)); BuildTelemetryClient.TrackEvent("IslandwoodBuildError", errorDetails, null); } } } }
private static bool IsError(IVsTaskItem taskItem) { var errorItem = taskItem as IVsErrorItem; if (errorItem == null) { return(false); } uint errorCategory; if (errorItem.GetCategory(out errorCategory).HasFailed()) { return(false); } return(errorCategory == (uint)__VSERRORCATEGORY.EC_ERROR); }
public static HashSet <string> CollectElementPathsFromToolWindowList( ToolWindowKind toolWindowKind) { HashSet <string> stringSet = new HashSet <string>(); IVsTaskList2 vsTaskList2 = (IVsTaskList2)null; switch (toolWindowKind) { case ToolWindowKind.ErrorList: vsTaskList2 = CoreUtility.ServiceProvider.GetService(typeof(SVsErrorList)) as IVsTaskList2; break; case ToolWindowKind.TaskList: vsTaskList2 = CoreUtility.ServiceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; break; } IVsEnumTaskItems ppEnum = (IVsEnumTaskItems)null; if (vsTaskList2 != null && ErrorHandler.Succeeded(vsTaskList2.EnumSelectedItems(out ppEnum))) { IVsTaskItem[] rgelt = new IVsTaskItem[1]; uint[] pceltFetched = new uint[1]; while (ppEnum.Next(1U, rgelt, pceltFetched) == 0) { if (rgelt != null && ((IEnumerable <IVsTaskItem>)rgelt).Count <IVsTaskItem>() > 0 && rgelt[0] != null) { string pbstrMkDocument = (string)null; if (ErrorHandler.Succeeded(rgelt[0].Document(out pbstrMkDocument)) && !string.IsNullOrWhiteSpace(pbstrMkDocument)) { if (pbstrMkDocument.EndsWith(".xpp", StringComparison.OrdinalIgnoreCase)) { stringSet.Add(CoreUtility.GetService <IMetadataInfoProvider>().GetXmlArtifactFilePath(pbstrMkDocument)); } else if (pbstrMkDocument.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) { stringSet.Add(pbstrMkDocument); } } } } } return(stringSet); }
public IEnumerable <IVsTaskItem> EnumerateErrors() { IVsEnumTaskItems taskEnumerator; if (_vsTaskList.EnumTaskItems(out taskEnumerator).HasFailed()) { yield break; } var vsTaskItem = new IVsTaskItem[1]; while (taskEnumerator.Next(1, vsTaskItem, null).HasWorked()) { var taskItem = vsTaskItem[0]; if (IsError(taskItem)) { yield return(taskItem); } } }
public IEnumerable <IVsTaskItem> GetErrorListItems() { IVsEnumTaskItems itemsEnum; _tasks.EnumTaskItems(out itemsEnum); IVsTaskItem[] oneItem = new IVsTaskItem[1]; List <IVsTaskItem> items = new List <IVsTaskItem>(); int result = 0; //S_OK == 0, S_FALSE == 1 do { result = itemsEnum.Next(1, oneItem, null); if (result == 0) { items.Add(oneItem[0]); } } while (result == 0); return(items); }
private void IgnoreSelectedItems(bool ignore) { int hr = VSConstants.S_OK; IVsTaskList2 taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; IVsEnumTaskItems enumerator = null; hr = taskList.EnumSelectedItems(out enumerator); Debug.Assert(hr == VSConstants.S_OK, "EnumSelectedItems did not return S_OK."); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { Task task = items[0] as Task; if (task != null) { task.Ignored = ignore; } } Refresh(); }
public TaskItemInfo(IVsTaskItem taskItem) { ErrorHandler.ThrowOnFailure(taskItem.Document(out Document)); ErrorHandler.ThrowOnFailure(taskItem.get_Text(out Message)); ErrorHandler.ThrowOnFailure(taskItem.Line(out Line)); ErrorHandler.ThrowOnFailure(taskItem.Column(out Column)); var priority = new VSTASKPRIORITY[1]; ErrorHandler.ThrowOnFailure(taskItem.get_Priority(priority)); Priority = priority[0]; var category = new VSTASKCATEGORY[1]; ErrorHandler.ThrowOnFailure(taskItem.Category(category)); Category = category[0]; var errorItem = taskItem as IVsErrorItem; if (errorItem != null) { uint errorCategory; ErrorHandler.ThrowOnFailure(errorItem.GetCategory(out errorCategory)); ErrorCategory = (__VSERRORCATEGORY)errorCategory; } else { ErrorCategory = null; } }
/// <summary> /// Enumerates a requested number of items. /// </summary> /// <param name="celt">The number of items to return.</param> /// <param name="rgelt">The array of items that will be returned.</param> /// <param name="pceltFetched">The array whose first element will be set to the actual number of items returned.</param> /// <returns>S_OK if all requested items were returned; S_FALSE if fewer were available; E_INVALIDARG if <c>celt</c> is less than zero, <c>rgelt</c> is null, or <c>pceltFetched</c> is null.</returns> /// <remarks> /// This method returns failure codes instead of throwing exceptions because it is intended to be called from native code. /// If the task provider's IsShowingIgnoredInstances property is false, ignored instances will be skipped. /// </remarks> public int Next(uint celt, IVsTaskItem[] rgelt, uint[] pceltFetched) { pceltFetched[0] = 0; while (pceltFetched[0] < celt && _next < _items.Count) { if (_showIgnored || !_items[_next].Ignored) { rgelt[pceltFetched[0]] = _items[_next]; pceltFetched[0]++; } ++_next; } if (pceltFetched[0] == celt) { return VSConstants.S_OK; } else { return VSConstants.S_FALSE; } }
public static IEnumerable <IVsTaskItem> AsEnumerable(this IVsEnumTaskItems items) { var item = new IVsTaskItem[1]; while (true) { var hr = items.Next(1, item, null); ErrorHandler.ThrowOnFailure(hr); if (hr == VSConstants.S_FALSE) { break; } // BEGIN WORKAROUND FOR https://github.com/dotnet/roslyn/issues/32121 // Filter out items not belonging to a currently-open project if (ErrorHandler.Failed(((IVsErrorItem)item[0]).GetHierarchy(out _))) { continue; } // END WORKAROUND FOR https://github.com/dotnet/roslyn/issues/32121 yield return(item[0]); } }
/// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.EmptyTaskList"]/*' /> /// <devdoc> /// Empty the task list. /// </devdoc> /// <param name="serviceProvider">The service provider.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public static int EmptyTaskList(IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentException("serviceProvider"); } IVsTaskList taskList = serviceProvider.GetService(typeof(IVsTaskList)) as IVsTaskList; if (taskList == null) { throw new InvalidOperationException(); } IVsEnumTaskItems enumTaskItems; int result = VSConstants.S_OK; try { ErrorHandler.ThrowOnFailure(taskList.EnumTaskItems(out enumTaskItems)); if (enumTaskItems == null) { throw new InvalidOperationException(); } // Retrieve the task item text and check whether it is equal with one that supposed to be thrown. uint[] fetched = new uint[1]; do { IVsTaskItem[] taskItems = new IVsTaskItem[1]; result = enumTaskItems.Next(1, taskItems, fetched); if (fetched[0] == 1) { IVsTaskItem2 taskItem = taskItems[0] as IVsTaskItem2; if (taskItem != null) { int canDelete; ErrorHandler.ThrowOnFailure(taskItem.CanDelete(out canDelete)); if (canDelete == 1) { ErrorHandler.ThrowOnFailure(taskItem.OnDeleteTask()); } } } } while (result == VSConstants.S_OK && fetched[0] == 1); } catch (COMException e) { Trace.WriteLine("Exception : " + e.Message); result = e.ErrorCode; } return result; }
/// <summary> /// The set selected. /// </summary> /// <param name="item"> /// The item. /// </param> /// <param name="selected"> /// The selected. /// </param> public void SetSelected(IVsTaskItem item, bool selected) { if (!selected) { this._selection.Remove(item); } else { if (!this._selection.Contains(item)) { this._selection.Add(item); } } }
public virtual int Next(uint celt, IVsTaskItem[] rgelt, uint[] pceltFetched) { uint fetched = 0; while (pos < tasks.Count && fetched < celt) { Task task = tasks[pos]; if (task != null && task.IsVisible()) { if (rgelt != null && rgelt.Length > fetched) { rgelt[fetched] = task; } fetched++; } pos++; } if (pceltFetched != null && pceltFetched.Length > 0) { pceltFetched[0] = fetched; } return (fetched < celt ? VSConstants.S_FALSE : 0); }
public int OnBeginTaskEdit(IVsTaskItem pItem) { return 0; }
/// <summary> /// The get caret pos. /// </summary> /// <param name="ppItem"> /// The pp item. /// </param> /// <returns> /// The get caret pos. /// </returns> /// <exception cref="Exception"> /// </exception> public int GetCaretPos(out IVsTaskItem ppItem) { throw new Exception("The method or operation is not implemented."); }
public static int GetColumn(this IVsTaskItem item) { ErrorHandler.ThrowOnFailure(item.Column(out var column)); return(column + 1); }
/// <summary> /// The begin task edit. /// </summary> /// <param name="pItem"> /// The p item. /// </param> /// <param name="iFocusField"> /// The i focus field. /// </param> /// <returns> /// The begin task edit. /// </returns> /// <exception cref="Exception"> /// </exception> public int BeginTaskEdit(IVsTaskItem pItem, int iFocusField) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// The get caret pos. /// </summary> /// <param name="ppItem"> /// The pp item. /// </param> /// <returns> /// The get caret pos. /// </returns> /// <exception cref="Exception"> /// </exception> public int GetCaretPos(out IVsTaskItem ppItem) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// The remove tasks. /// </summary> /// <param name="vsProviderCookie"> /// The vs provider cookie. /// </param> /// <param name="nTasks"> /// The n tasks. /// </param> /// <param name="prgTasks"> /// The prg tasks. /// </param> /// <returns> /// The remove tasks. /// </returns> /// <exception cref="Exception"> /// </exception> public int RemoveTasks(uint vsProviderCookie, int nTasks, IVsTaskItem[] prgTasks) { throw new Exception("The method or operation is not implemented."); }
protected IVsTask RemoveTasks(IVsTaskItem[] oldTasks) { return _tasklist.RemoveTasksAsync(_providerCookie, oldTasks.Length, oldTasks); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.IVsTaskProvider3.OnEndTaskEdit"]/*' /> // Called when the user finishes editing a task in-place. fCommitChanges indicates whether the // user chose to commit the changes or discard them. This method may set *pfAllowChanges to // FALSE to disallow the user from exiting edit mode. If fCommitChanges is TRUE, the changes // will have already been persisted down to the task item. int IVsTaskProvider3.OnEndTaskEdit(IVsTaskItem item, int fCommitChanges, out int fAllowChanges) { fAllowChanges = 1; return NativeMethods.S_OK; }
/// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.GetTaskItems2"]/*' /> /// <devdoc> /// Get list of all tasks items. /// </devdoc> /// <param name="serviceProvider">The service provider.</param> /// <returns>A list of task items.</returns> public static IList<IVsTaskItem> GetTaskItems2(IServiceProvider serviceProvider) { IList<IVsTaskItem> tasks = new List<IVsTaskItem>(); if (serviceProvider == null) { throw new ArgumentException("serviceProvider"); } IVsTaskList taskList = serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; if (taskList == null) { throw new InvalidOperationException(); } IVsEnumTaskItems enumTaskItems; try { ErrorHandler.ThrowOnFailure(taskList.EnumTaskItems(out enumTaskItems)); if (enumTaskItems == null) { return tasks; } int result = VSConstants.E_FAIL; uint[] fetched = new uint[1]; do { IVsTaskItem[] taskItems = new IVsTaskItem[1]; result = enumTaskItems.Next(1, taskItems, fetched); if (fetched[0] == 1) { IVsTaskItem taskItem = taskItems[0]; tasks.Add(taskItem); } } while (result == VSConstants.S_OK && fetched[0] == 1); } catch (COMException e) { Trace.WriteLine("Exception : " + e.Message); } return tasks; }
public IEnumerable<IVsTaskItem> GetErrorListItems() { IVsEnumTaskItems itemsEnum; _tasks.EnumTaskItems(out itemsEnum); var oneItem = new IVsTaskItem[1]; var items = new List<IVsTaskItem>(); var result = 0; do { result = itemsEnum.Next(1, oneItem, null); if (result == 0) { items.Add(oneItem[0]); } } while (result == 0); return items; }
public int OnEndTaskEdit(IVsTaskItem pItem, int fCommitChanges, out int pfAllowChanges) { pfAllowChanges = 0; return(VSConstants.E_NOTIMPL); }
public static int GetLine(this IVsTaskItem item) { ErrorHandler.ThrowOnFailure(item.Line(out var line)); return(line + 1); }
public int OnBeginTaskEdit(IVsTaskItem pItem) { return VSConstants.E_NOTIMPL; }
/// <summary> /// The begin task edit. /// </summary> /// <param name="pItem"> /// The p item. /// </param> /// <param name="iFocusField"> /// The i focus field. /// </param> /// <returns> /// The begin task edit. /// </returns> /// <exception cref="Exception"> /// </exception> public int BeginTaskEdit(IVsTaskItem pItem, int iFocusField) { throw new Exception("The method or operation is not implemented."); }
List<Task> GetSelectedTasks() { var result = new List<Task>(); int hr = VSConstants.S_OK; var taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; if (taskList == null) { Debug.Fail("Failed to get SVsTaskList service."); return result; } IVsEnumTaskItems enumerator = null; hr = taskList.EnumSelectedItems(out enumerator); Debug.Assert(hr == VSConstants.S_OK, "EnumSelectedItems did not return S_OK."); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { Task task = items[0] as Task; if (task != null) { result.Add(task); } } return result; }
/// <summary> /// Skips a specified number of items /// </summary> /// <param name="celt">The number of items to skip.</param> /// <returns>S_OK if the requested number of items was skipped; S_FALSE if <c>celt</c> is larger than the number of available items; E_INVALIDARG if <c>celt</c> is less than zero.</returns> /// <remarks> /// This method returns failure codes instead of throwing exceptions because it is intended to be called from native code. /// If the task provider's IsShowingIgnoredInstances property is false, ignored instances will not be counted. /// </remarks> public int Skip(uint celt) { IVsTaskItem[] items = new IVsTaskItem[celt]; uint[] fetched = new uint[] { 0 }; return Next(celt, items, fetched); }
private void IgnoreSelectedItems(bool ignore) { int hr = VSConstants.S_OK; IVsTaskList2 taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; IVsEnumTaskItems enumerator = null; hr = taskList.EnumSelectedItems(out enumerator); Debug.Assert(hr == VSConstants.S_OK, "EnumSelectedItems did not return S_OK."); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { Task task = items[0] as Task; if (task != null) { task.Ignored = ignore; } } Refresh(); }
public int OnEndTaskEdit(IVsTaskItem pItem, int fCommitChanges, out int pfAllowChanges) { pfAllowChanges = 1; return VSConstants.E_NOTIMPL; }
public virtual int Next(uint celt, IVsTaskItem[] rgelt, uint[] pceltFetched) { uint count = 0; for (uint i = pos, n = (uint)Math.Min(pos+celt, items.Length); rgelt != null && i<n; i++) { rgelt[count++] = items[i]; } if (count == 0) return (int)HResult.S_FALSE; if (pceltFetched != null) pceltFetched[0] = count; pos += count; return 0; }
public int OnBeginTaskEdit(IVsTaskItem pItem) { return(VSConstants.E_NOTIMPL); }
/// <summary> /// The select items. /// </summary> /// <param name="nItems"> /// The n items. /// </param> /// <param name="pItems"> /// The p items. /// </param> /// <param name="tsfSelType"> /// The tsf sel type. /// </param> /// <param name="tsspScrollPos"> /// The tssp scroll pos. /// </param> /// <returns> /// The select items. /// </returns> /// <exception cref="Exception"> /// </exception> public int SelectItems(int nItems, IVsTaskItem[] pItems, uint tsfSelType, uint tsspScrollPos) { throw new Exception("The method or operation is not implemented."); }
private void ProcessTaskListItem(IVsTaskItem taskListItem) { IVsErrorItem errorTaskItem = taskListItem as IVsErrorItem; if (errorTaskItem != null) { uint errorCategory = 255; errorTaskItem.GetCategory(out errorCategory); // is this task an error from an Islandwood project if (errorCategory == (uint)TaskErrorCategory.Error || errorCategory == (uint)TaskErrorCategory.Warning) { string sourceFile = string.Empty; taskListItem.Document(out sourceFile); if (string.IsNullOrEmpty(sourceFile) == false && (sourceFile.EndsWith(".m") || sourceFile.EndsWith(".mm") || sourceFile.EndsWith(".h"))) { Dictionary<string, string> errorDetails = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); errorDetails.Add("BuildId", _currentBuildGuid.ToString()); Guid errorProjectGuid = _firstIslandwoodProjectGuid; IVsHierarchy errorTaskItemHierarchy = null; if (errorTaskItem.GetHierarchy(out errorTaskItemHierarchy) == 0 && errorTaskItemHierarchy != null) { _solution.GetGuidOfProject(errorTaskItemHierarchy, out errorProjectGuid); } errorDetails.Add("ProjectId", errorProjectGuid.ToString()); string errorCategoryText = errorCategory == 0 ? TaskErrorCategory.Error.ToString() : TaskErrorCategory.Warning.ToString(); errorDetails.Add("Category", errorCategoryText); string rawErrorText = string.Empty; taskListItem.get_Text(out rawErrorText); errorDetails.Add("Description", ParseAndScrubErrorMessage(rawErrorText)); BuildTelemetryClient.TrackEvent("IslandwoodBuildError", errorDetails, null); } } } }
public Threading.Task SendErrorDetails(IVsTaskList errorList) { Threading.Task processTaskListTask = new System.Threading.Tasks.Task(() => { _processorStopwatch.Start(); IVsEnumTaskItems taskEnum = null; IVsTaskItem[] oneItem = new IVsTaskItem[1]; if (errorList != null) { try { errorList.EnumTaskItems(out taskEnum); if (taskEnum != null) { int maxItems = 10000; Int32.TryParse(Properties.Resources.MaxErrorsToProcess, out maxItems); taskEnum.Next(1, oneItem, null); for (int i = 0; (i < maxItems) && (oneItem[0] != null); ++i) { ProcessTaskListItem(oneItem[0]); taskEnum.Next(1, oneItem, null); } } } catch (Exception e) { Dictionary<string, string> exceptionDetails = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); exceptionDetails.Add("BuildId", _currentBuildGuid.ToString()); exceptionDetails.Add("ProjectId", _firstIslandwoodProjectGuid.ToString()); exceptionDetails.Add("Exception", e.GetType().ToString()); exceptionDetails.Add("Message", e.Message); exceptionDetails.Add("InnerException", (e.InnerException == null ? "null" : e.InnerException.GetType().ToString())); exceptionDetails.Add("InnerMessage", (e.InnerException == null ? "null" : e.InnerException.Message)); BuildTelemetryClient.TrackEvent("IslandwoodBuildMonitorException", exceptionDetails, null); } finally { // send all events in case the Visual Studio instance is closed or solution unloaded BuildTelemetryClient.FlushEvents(); } } _processorStopwatch.Stop(); Dictionary<string, string> perfProperties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); perfProperties.Add("BuildId", _currentBuildGuid.ToString()); perfProperties.Add("ProjectId", _firstIslandwoodProjectGuid.ToString()); Dictionary<string, double> perfMetrics = new Dictionary<string, double>(StringComparer.OrdinalIgnoreCase); perfMetrics.Add("ProcessTasks", _processorStopwatch.ElapsedMilliseconds); BuildTelemetryClient.TrackEvent("IslandwoodBuildMonitorPerformance", perfProperties, perfMetrics); // reset state in case projects/solutions are unloaded before next build _firstIslandwoodProjectGuid = Guid.Empty; }); processTaskListTask.Start(); return processTaskListTask; }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.IVsTaskProvider3.OnBeginTaskEdit"]/*' /> // Called when the user begins editing a task in-place. Providers may want to avoid scrolling // the tasklist or changing the selection during editing, since these actions can force in- // place edit mode to be canceled abruptly. int IVsTaskProvider3.OnBeginTaskEdit(IVsTaskItem item) { return NativeMethods.S_OK; }
public List<IVsTaskItem> GetErrorListItems() { IVsEnumTaskItems itemsEnum; _tasks.EnumTaskItems(out itemsEnum); IVsTaskItem[] oneItem = new IVsTaskItem[1]; List<IVsTaskItem> items = new List<IVsTaskItem>(); int result = 0; //S_OK == 0, S_FALSE == 1 do { result = itemsEnum.Next(1, oneItem, null); if (result == 0) { items.Add(oneItem[0]); } } while (result == 0); return items; }
public int Next(uint celt, IVsTaskItem[] items, uint[] pceltFetched) { if (items == null || items.Length < celt) throw new ArgumentException(String.Empty, "items"); uint fetched = 0; while (fetched < celt && taskEnum.MoveNext()) { items[fetched++] = (IVsTaskItem)taskEnum.Current; } if (pceltFetched != null && pceltFetched.Length > 0) { pceltFetched[0] = fetched; } if (fetched == 0 && celt > 0) { return NativeMethods.S_FALSE; } return NativeMethods.S_OK; }
public int Next(uint celt, IVsTaskItem[] rgelt, uint[] pceltFetched) { return VSConstants.E_NOTIMPL; }