internal static DesignerErrorList GetSingleDocErrorList(IVsHierarchy hier, uint ItemID) { DesignerErrorList errorList = null; // // assert that the solution is open & not closing. Otherwise, this method will add new entries into the _singleDocErrorLists. // these entries will hold a ref to IVsHierarchy, and prevent the IVsHierarchy from being GC'd. // Debug.Assert( EdmSolutionEvents.Instance.IsAfterErrorListClearedOnSolutionClose == false, "unexpected solution state during GetSingleDocErrorList. This should only be called if the solution is open."); if (EdmSolutionEvents.Instance.IsAfterErrorListClearedOnSolutionClose == false) { _singleDocErrorLists.TryGetValue(new SingleDocErrorListsIdentifier(hier, ItemID), out errorList); // Create a new error list if one doesn't already exist for the given document if (errorList == null) { errorList = new DesignerErrorList(PackageManager.Package); _singleDocErrorLists.Add(new SingleDocErrorListsIdentifier(hier, ItemID), errorList); } } return(errorList); }
internal static void AddErrorInfosToErrorList( ICollection <ErrorInfo> errors, IVsHierarchy vsHierarchy, uint itemID, DesignerErrorList errorList, bool bringErrorListToFront = false) { errorList.Clear(); var errorCount = 0; foreach (var error in errors) { if (errorCount++ > 99) { break; } var errorTask = EFModelErrorTaskFactory.CreateErrorTask(error, vsHierarchy, itemID); errorList.AddItem(errorTask); } if (errors.Count > 0) { errorList.Provider.Show(); if (bringErrorListToFront) { errorList.Provider.BringToFront(); } } }
internal static DesignerErrorList GetSingleDocErrorList(Uri uri) { DesignerErrorList errorList = null; var currentProject = VSHelpers.GetProjectForDocument(uri.LocalPath, PackageManager.Package); if (currentProject != null) { var hierarchy = VsUtils.GetVsHierarchy(currentProject, Services.ServiceProvider); if (hierarchy != null) { var fileFinder = new VSFileFinder(uri.LocalPath); fileFinder.FindInProject(hierarchy); Debug.Assert(fileFinder.MatchingFiles.Count <= 1, "Unexpected count of matching files in project"); foreach (var vsFileInfo in fileFinder.MatchingFiles) { if (vsFileInfo.Hierarchy == VsUtils.GetVsHierarchy(currentProject, Services.ServiceProvider)) { errorList = GetSingleDocErrorList(vsFileInfo.Hierarchy, vsFileInfo.ItemId); break; } } } } return(errorList); }
private static DesignerErrorList LazilyLoadMultiDocErrorList( IServiceProvider serviceProvider, MultiDocErrorListIdentifier identifier) { var edmErrorList = GetMultiDocErrorList(identifier); if (edmErrorList == null) { edmErrorList = new DesignerErrorList(serviceProvider); _multiDocErrorLists.Add(identifier, edmErrorList); } return(edmErrorList); }
public void Can_add_clear_error_list_tasks() { var mockServiceProvider = new Mock<IServiceProvider>(); mockServiceProvider.Setup(p => p.GetService(typeof(SVsTaskList))).Returns(new Mock<IVsTaskList>().Object); var task = new ErrorTask(); var errorList = new DesignerErrorList(mockServiceProvider.Object); Assert.Empty(errorList.Provider.Tasks); errorList.AddItem(task); Assert.Equal(new[] { task }, errorList.Provider.Tasks.Cast<ErrorTask>()); errorList.Clear(); Assert.Empty(errorList.Provider.Tasks); }
private static bool TryGetSingleDocErrorList( IVsHierarchy hier, uint ItemID, out SingleDocErrorListsIdentifier id, out DesignerErrorList errorList) { id = new SingleDocErrorListsIdentifier(hier, ItemID); if (_singleDocErrorLists == null) { errorList = null; return(false); } else { return(_singleDocErrorLists.TryGetValue(id, out errorList)); } }
public void Can_add_clear_error_list_tasks() { var mockServiceProvider = new Mock <IServiceProvider>(); mockServiceProvider.Setup(p => p.GetService(typeof(SVsTaskList))).Returns(new Mock <IVsTaskList>().Object); var task = new ErrorTask(); var errorList = new DesignerErrorList(mockServiceProvider.Object); Assert.Empty(errorList.Provider.Tasks); errorList.AddItem(task); Assert.Equal(new[] { task }, errorList.Provider.Tasks.Cast <ErrorTask>()); errorList.Clear(); Assert.Empty(errorList.Provider.Tasks); }