public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { ppenum = null; Debugger.Break(); return(0); }
/// <summary> /// Returns a list of controllable projects in the solution /// </summary> public List <IVsSccProject2> GetLoadedControllableProjects() { var list = new List <IVsSccProject2>(); IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution)); list.Add(sol as IVsSccProject2); Guid rguidEnumOnlyThisType = new Guid(); IEnumHierarchies ppenum = null; ErrorHandler.ThrowOnFailure(sol.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum)); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2; if (sccProject2 != null) { list.Add(sccProject2); } } return(list); }
public static async Task <List <IVsSccProject2> > GetLoadedControllableProjects() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var list = new List <IVsSccProject2>(); IVsSolution sol = await GetActiveSolution(); list.Add(sol as IVsSccProject2); Guid rguidEnumOnlyThisType = new Guid(); IEnumHierarchies ppenum = null; ErrorHandler.ThrowOnFailure(sol.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum)); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2; if (sccProject2 != null && await IsProjectInGitRepoitory(sccProject2)) { list.Add(sccProject2); } } return(list); }
/// <summary> /// Returns a list of controllable projects in the solution /// </summary> internal Hashtable GetLoadedControllableProjectsEnum() { Hashtable mapHierarchies = new Hashtable(); IVsSolution sol = (IVsSolution)GetService(typeof(SVsSolution)); Guid rguidEnumOnlyThisType = new Guid(); IEnumHierarchies ppenum = null; ErrorHandler.ThrowOnFailure(sol.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum)); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2; if (sccProject2 != null) { mapHierarchies[rgelt[0]] = true; } } return(mapHierarchies); }
public static IEnumerable <IVsProject> GetProjectsOfCurrentSolution( this IVsSolution solutionService) { if (solutionService == null) { throw new ArgumentNullException(nameof(solutionService)); } IEnumHierarchies enumerator = null; Guid guid = Guid.Empty; solutionService.GetProjectEnum( (uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumerator); IVsHierarchy[] hierarchy = new IVsHierarchy[1] { null }; uint fetched = 0; for (enumerator.Reset(); enumerator.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1; /*nothing*/) { yield return((IVsProject)hierarchy[0]); } }
internal void InitProjectInfos(SVsServiceProvider provider, ABnfFactory factory) { if (factory == null) { return; } if (m_server != null) { return; } m_server = new ALanguageServer(); m_server.Start(factory); if (m_cookie != 0) { return; } if (m_solution != null) { return; } m_solution = provider.GetService(typeof(SVsSolution)) as IVsSolution; if (m_solution == null) { return; } m_dot_ext = factory.GetDotExt(); m_file_icon = factory.GetFileIcon(); // 读取所有工程 m_projects.Clear(); Guid rguidEnumOnlyThisType = new Guid(); IEnumHierarchies ppenum = null; m_solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2; if (sccProject2 != null) { string project_path = GetProjectPath(rgelt[0]); if (project_path != null) { if (m_server != null) { m_server.AddTask(() => m_server.AddProjectInfo(project_path)); } m_projects[rgelt[0]] = new UIProjectInfo(this, rgelt[0], project_path, m_dot_ext, m_file_icon); } } } // 监听工程变化 m_solution.AdviseSolutionEvents(this, out m_cookie); }
private List <ProjectReferenceNode> GetProjectReferencesContainingThisProject(IVsHierarchy inputHierarchy) { List <ProjectReferenceNode> projectReferences = new List <ProjectReferenceNode>(); if (this.Solution == null || inputHierarchy == null) { return(projectReferences); } uint flags = (uint)(__VSENUMPROJFLAGS.EPF_ALLPROJECTS | __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION); Guid enumOnlyThisType = Guid.Empty; IEnumHierarchies enumHierarchies = null; ThreadHelper.ThrowIfNotOnUIThread(); ErrorHandler.ThrowOnFailure(this.Solution.GetProjectEnum(flags, ref enumOnlyThisType, out enumHierarchies)); Debug.Assert(enumHierarchies != null, "Could not get list of hierarchies in solution"); IVsHierarchy[] hierarchies = new IVsHierarchy[1]; uint fetched; int returnValue = VSConstants.S_OK; do { returnValue = enumHierarchies.Next(1, hierarchies, out fetched); Debug.Assert(fetched <= 1, "We asked one project to be fetched VSCore gave more than one. We cannot handle that"); if (returnValue == VSConstants.S_OK && fetched == 1) { IVsHierarchy hierarchy = hierarchies[0]; Debug.Assert(hierarchy != null, "Could not retrieve a hierarchy"); IReferenceContainerProvider provider = hierarchy as IReferenceContainerProvider; if (provider != null) { IReferenceContainer referenceContainer = provider.GetReferenceContainer(); Debug.Assert(referenceContainer != null, "Could not found the References virtual node"); ProjectReferenceNode projectReferenceNode = GetProjectReferenceOnNodeForHierarchy(referenceContainer.EnumReferences(), inputHierarchy); if (projectReferenceNode != null) { projectReferences.Add(projectReferenceNode); } } } } while(returnValue == VSConstants.S_OK && fetched == 1); return(projectReferences); }
private bool LoadProjects() { var solution = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution; if (solution == null) { GeneralUtils.ShowMessage("Failed to get Solution service", OLEMSGICON.OLEMSGICON_CRITICAL); return(false); } // Verify that the solution and all its projects are fully loaded var solution4 = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution4; solution4.EnsureSolutionIsLoaded(0); IEnumHierarchies enumerator = null; Guid guid = Guid.Empty; solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumerator); IVsHierarchy[] hierarchy = new IVsHierarchy[1] { null }; uint fetched = 0; try { for (enumerator.Reset(); enumerator.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1; /*nothing*/) { // Verify that this is a project node and not a folder IVsProject project = (IVsProject)hierarchy[0]; string path; int hr = project.GetMkDocument((uint)VSConstants.VSITEMID.Root, out path); if (hr == VSConstants.S_OK) { AddNewProject(project); } } } catch (Exception) { GeneralUtils.ShowMessage("Failed to load projects info", OLEMSGICON.OLEMSGICON_CRITICAL); return(false); } return(true); }
/// <summary> /// Returns a list of solution folders projects in the solution /// </summary> public Hashtable GetSolutionFoldersEnum() { Hashtable mapHierarchies = new Hashtable(); IVsSolution sol = (IVsSolution)GetService(typeof(SVsSolution)); Guid rguidEnumOnlyThisType = guidSolutionFolderProject; IEnumHierarchies ppenum = null; ErrorHandler.ThrowOnFailure(sol.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum)); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { mapHierarchies[rgelt[0]] = true; } return(mapHierarchies); }
/// <summary> /// Enum all projects in the solution and collect all that derives from ProjectContainerNode /// </summary> /// <returns>List of ProjectContainerNode nodes</returns> private List <IBuildDependencyOnProjectContainer> GetListOfProjectContainerNodes() { List <IBuildDependencyOnProjectContainer> projectList = new List <IBuildDependencyOnProjectContainer>(); Debug.Assert(this.Solution != null, "IVsSolution object not set on this object"); if (this.Solution == null) { // Bad state, so we quit return(projectList); } // Enum projects loaded in the solution (normal projects only) IEnumHierarchies enumHierarchies = null; Guid guid = Guid.Empty; __VSENUMPROJFLAGS flags = __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION; ThreadHelper.ThrowIfNotOnUIThread(); ErrorHandler.ThrowOnFailure(this.Solution.GetProjectEnum((uint)flags, ref guid, out enumHierarchies)); ThreadHelper.ThrowIfNotOnUIThread(); if (enumHierarchies != null) { // Loop projects found IVsHierarchy[] hierarchy = new IVsHierarchy[1]; uint fetched = 0; while (enumHierarchies.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1) { // If this is a ProjectContainerNode then add to list IBuildDependencyOnProjectContainer projectNode = hierarchy[0] as IBuildDependencyOnProjectContainer; if (projectNode != null) { projectList.Add(projectNode); } } } return(projectList); }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { __VSENUMPROJFLAGS flags = (__VSENUMPROJFLAGS)grfEnumFlags; ProjectInfo[] projects; if (flags.HasFlag(__VSENUMPROJFLAGS.EPF_MATCHTYPE)) { var guid = rguidEnumOnlyThisType; projects = _projects.Values.Where(x => x.ProjectGuid == guid).ToArray(); } else if (flags.HasFlag(__VSENUMPROJFLAGS.EPF_ALLPROJECTS)) { projects = _projects.Values.ToArray(); } else { throw new NotImplementedException(); } ppenum = new ProjectEnum(projects); return(VSConstants.S_OK); }
internal static IEnumerable <IVsHierarchy> GetProjectsInSolution(IVsSolution solution) { if (solution == null) { throw new ArgumentNullException("solution"); } IEnumHierarchies penum = null; var nullGuid = Guid.Empty; var hr = solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_ALLPROJECTS, ref nullGuid, out penum); if (ErrorHandler.Succeeded(hr) && (penum != null)) { uint fetched = 0; var rgelt = new IVsHierarchy[1]; while (penum.Next(1, rgelt, out fetched) == 0 && fetched == 1) { yield return(rgelt[0]); } } }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { ppenum = null; return(VSConstants.S_OK); }
int IEnumHierarchies.Clone(out IEnumHierarchies ppenum) { ppenum = new EnumHierarchies(this); return(VSConstants.S_OK); }
int IVsSolution2.GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { throw new NotImplementedException(); }
int IVsSolution.GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { ((__VSENUMPROJFLAGS)grfEnumFlags).Should().Be(__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, "Unexpected argument value grfEnumFlags"); ppenum = new EnumHierarchies(this); return(VSConstants.S_OK); }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { ppenum = new MockEnumHierarchies(_projects); return VSConstants.S_OK; }
/// <summary> /// The clone. /// </summary> /// <param name="ppenum"> /// The ppenum. /// </param> /// <returns> /// The clone. /// </returns> public int Clone(out IEnumHierarchies ppenum) { ppenum = new MockEnumHierarchies(this._projects); return VSConstants.S_OK; }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { ppenum = null; return VSConstants.E_NOTIMPL; }
public int Clone(out IEnumHierarchies ppenum) { ppenum = For(_projects); return(VSConstants.S_OK); }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { return(_solution.GetProjectEnum(grfEnumFlags, ref rguidEnumOnlyThisType, out ppenum)); }
/// <summary> /// The clone. /// </summary> /// <param name="ppenum"> /// The ppenum. /// </param> /// <returns> /// The clone. /// </returns> public int Clone(out IEnumHierarchies ppenum) { ppenum = new MockEnumHierarchies(this._projects); return(VSConstants.S_OK); }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { __VSENUMPROJFLAGS flags = (__VSENUMPROJFLAGS)grfEnumFlags; ProjectInfo[] projects; if (flags.HasFlag(__VSENUMPROJFLAGS.EPF_MATCHTYPE)) { var guid = rguidEnumOnlyThisType; projects = _projects.Values.Where(x => x.ProjectGuid == guid).ToArray(); } else if (flags.HasFlag(__VSENUMPROJFLAGS.EPF_ALLPROJECTS)) { projects = _projects.Values.ToArray(); } else { throw new NotImplementedException(); } ppenum = new ProjectEnum(projects); return VSConstants.S_OK; }
public int Clone(out IEnumHierarchies ppenum) { ppenum = new ProjectEnum(_projects); return VSConstants.S_OK; }
private static void GetProjectAndFileInfoForPath( string originalPath, IServiceProvider serviceProvider, IVsSolution solution, out IVsHierarchy projectHierarchy, out Project project, out uint fileItemId, out bool isDocumentInProject) { var guid = Guid.Empty; IEnumHierarchies hierarchyEnum = null; fileItemId = VSConstants.VSITEMID_NIL; projectHierarchy = null; isDocumentInProject = false; project = null; if (solution != null) { var hr = solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_ALLPROJECTS, ref guid, out hierarchyEnum); if (NativeMethods.Succeeded(hr) && hierarchyEnum != null) { hierarchyEnum.Reset(); uint numFetched = 1; var item = new IVsHierarchy[1]; hierarchyEnum.Next(1, item, out numFetched); while (numFetched == 1) { var vsProject = item[0] as IVsProject; if (vsProject != null) { GetProjectAndFileInfoForPath( vsProject, originalPath, out projectHierarchy, out project, out fileItemId, out isDocumentInProject); if (isDocumentInProject) { break; } } hierarchyEnum.Next(1, item, out numFetched); } } } // didn't find a project, so check the misc files project if (project == null) { // // try not to create the Misc files project externally - in some rare cases it has caused Access violoations in VS (e.g., Dev10 Bug 864725). // So, only create this if we really need it. // IVsProject3 miscFilesProject = null; if (serviceProvider == null) { miscFilesProject = GetMiscellaneousProject(); } else { miscFilesProject = GetMiscellaneousProject(serviceProvider); } if (miscFilesProject != null) { GetProjectAndFileInfoForPath( miscFilesProject, originalPath, out projectHierarchy, out project, out fileItemId, out isDocumentInProject); if (project == null) { projectHierarchy = miscFilesProject as IVsHierarchy; if (projectHierarchy != null) { project = GetProject(projectHierarchy); } } } } }
public int GetProjectEnum(uint grfEnumFlags, ref Guid rguidEnumOnlyThisType, out IEnumHierarchies ppenum) { ppenum = HierarchyEnumerator.For(_projects.Cast <IVsHierarchy>()); return(VSConstants.S_OK); }
int IVsSolution.GetProjectEnum(uint enumFlags, ref Guid enumOnlyThisType, out IEnumHierarchies enumHierarchies) { throw new NotImplementedException(); }