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); }
List <Task> SelectedTasks() { List <Task> result = new List <Task>(); 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) { result.Add(task); } } return(result); }
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 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]); } }
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); }
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 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]); } }