private void DisplaySourceItemsInErrorList(IEnumerable <ISourceMappedItem> items, ICollection <Project> projects) { if (!items.Any()) { return; } _errorList.Tasks.Clear(); _errorList.Refresh(); _errorList.SuspendRefresh(); try { // Using a single project for this appears to work, but there may be a better way var hierarchy = projects.First().GetHierarchy(); foreach (var item in items) { if (!_fileSystem.FileExists(item.Path)) { continue; } var errorWindowTask = item.GetErrorWindowTask(hierarchy); var result = _errorList.Tasks.Add(errorWindowTask); } } finally { _errorList.ResumeRefresh(); } // Outside the finally because it will obscure errors reported on the output window _errorList.BringToFront(); }
public async Task DisplaySourceItemsAsync(IEnumerable <ISourceMappedItem> items, ICollection <CalculatedProject> projects) { await _threadingService.SwitchToMainThreadAsync(); _errorList.Tasks.Clear(); _errorList.Refresh(); _errorList.SuspendRefresh(); var projectWithOutputMappings = new ConcurrentDictionary <string, IVsHierarchy>(); foreach (var calculatedProject in projects) { var project = calculatedProject.Project; var outputs = calculatedProject.OutputFiles; if (outputs == null) { continue; } var hierarchy = calculatedProject.VsHierarchy; foreach (var output in outputs) { projectWithOutputMappings.AddOrUpdate(output, hierarchy, (existingKey, existingValue) => hierarchy); } } await _threadingService.SwitchToMainThreadAsync(); try { var defaultHierarchy = projects.First().VsHierarchy; foreach (var item in items) { if (!_fileSystem.FileExists(item.Path)) { continue; } if (!projectWithOutputMappings.TryGetValue(item.Assembly, out IVsHierarchy hierarchy)) { hierarchy = defaultHierarchy; } var errorWindowTask = item.GetErrorWindowTask(hierarchy); var result = _errorList.Tasks.Add(errorWindowTask); } } finally { _errorList.ResumeRefresh(); } // Outside the finally because it will obscure errors reported on the output window _errorList.BringToFront(); }