internal BuildEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsSolutionBuildManager svc = VS.GetRequiredService <SVsSolutionBuildManager, IVsSolutionBuildManager>(); svc !.AdviseUpdateSolutionEvents(this, out _); }
internal ProjectItemsEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsTrackProjectDocuments2 tpd = VS.GetRequiredService <SVsTrackProjectDocuments, IVsTrackProjectDocuments2>(); tpd.AdviseTrackProjectDocumentsEvents(this, out _); }
internal SolutionEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsSolution svc = VS.GetRequiredService <SVsSolution, IVsSolution>(); svc.AdviseSolutionEvents(this, out _); }
internal SelectionEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsMonitorSelection monitor = VS.GetRequiredService <SVsShellMonitorSelection, IVsMonitorSelection>(); monitor.AdviseSelectionEvents(this, out _); }
internal DebuggerEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsDebugger svc = VS.GetRequiredService <IVsDebugger, IVsDebugger>(); svc.AdviseDebuggerEvents(this, out _); }
internal WindowEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell7 svc = VS.GetRequiredService <SVsUIShell, IVsUIShell7>(); svc.AdviseWindowFrameEvents(this); }
/// <summary> /// Gets the current solution. /// </summary> public Solution?GetCurrentSolution() { ThreadHelper.ThrowIfNotOnUIThread(); IVsHierarchy solution = VS.GetRequiredService <SVsSolution, IVsHierarchy>(); IVsHierarchyItem?hierItem = solution.ToHierarchyItem(VSConstants.VSITEMID_ROOT); return(SolutionItem.FromHierarchyItem(hierItem) as Solution); }
internal ShellEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsShell svc = VS.GetRequiredService <SVsShell, IVsShell>(); svc.AdviseShellPropertyChanges(this, out _); svc.AdviseBroadcastMessages(this, out _); }
/// <inheritdoc/> public IEnumerator <Reference> GetEnumerator() { ThreadHelper.ThrowIfNotOnUIThread(); // Not all projects can have references (for example Shared Projects), // so when enumerating over the references in the project, we won't throw // an error if the manager or provider context cannot be retrieved. if (TryGetManager(out IVsReferenceManagerUser manager)) { IVsSharedProjectReferenceProviderContext?sharedProjectContext = null; foreach (IVsReferenceProviderContext context in manager.GetProviderContexts().OfType <IVsReferenceProviderContext>()) { // Remember the shared project context, because it may not actually provide the // references to shared projects, meaning we may have to create them ourselves. if (context is IVsSharedProjectReferenceProviderContext shared) { sharedProjectContext = shared; } foreach (IVsReference reference in context.References.OfType <IVsReference>()) { if (reference is IVsAssemblyReference assemblyReference) { yield return(new AssemblyReference(assemblyReference)); } else if (reference is IVsProjectReference projectReference) { yield return(new ProjectReference(projectReference)); } else { yield return(new Reference(reference)); } } } // Shared projects don't seem to be listed in the provider contexts, so if there is a context // for shared projects but it's empty, then we'll define the shared project references ourselves. if (sharedProjectContext is not null && sharedProjectContext.References.Length == 0) { IVsSolution?solution = null; _project.GetItemInfo(out IVsHierarchy hierarchy, out _, out _); foreach (IVsHierarchy sharedHierarchy in hierarchy.EnumOwningProjectsOfSharedAssets()) { // A shared project seems to list itself as an owning project, so ignore // this hierarchy if it's the same one that we got from our project. if (sharedHierarchy == hierarchy) { continue; } IVsSharedAssetsProject?sharedProject = sharedHierarchy.GetSharedAssetsProject(); if (sharedProject is not null) { Project?project = SolutionItem.FromHierarchy(sharedHierarchy, VSConstants.VSITEMID_ROOT) as Project; if (project is not null) { if (solution is null) { solution = VS.GetRequiredService <SVsSolution, IVsSolution>(); } IVsSharedProjectReference reference = (IVsSharedProjectReference)sharedProjectContext.CreateReference(); PopulateSharedProjectReference(reference, solution, project, sharedProject); yield return(new ProjectReference(reference)); } } } } } }