public IUnconfiguredProjectVsServicesMock ImplementVsProject(IVsProject4 project) { SetupGet(m => m.VsProject) .Returns(project); return(this); }
private bool ExistInProjectFast(IVsProject4 vsp4) { var pfDoesContain = 0; VSErrorHandler.ThrowOnFailure(vsp4.ContainsFileEndingWith(_input, out pfDoesContain)); return(pfDoesContain != 0); }
public static void ImplementOpenItemWithSpecific(this IVsProject4 project, Guid editorType, Guid logicalView, IVsWindowFrame?frame) { var mock = Mock.Get(project); mock.Setup(h => h.OpenItemWithSpecific(It.IsAny <uint>(), It.IsAny <uint>(), ref editorType, It.IsAny <string>(), ref logicalView, It.IsAny <IntPtr>(), out frame)) .Returns(0); }
protected AbstractHostObject(IVsHierarchy innerHierarchy, IVsProject4 innerVsProject) { Requires.NotNull(innerHierarchy, nameof(innerHierarchy)); Requires.NotNull(innerVsProject, nameof(innerVsProject)); InnerHierarchy = innerHierarchy; InnerVsProject = innerVsProject; }
/// <summary> /// Opens the specified item with the specified editor using the primary logical view. /// </summary> /// <returns> /// The <see cref="IVsWindowFrame"/> that contains the editor; otherwise, <see langword="null"/> if it was opened /// with an editor external of Visual Studio. /// </returns> public static IVsWindowFrame?OpenItemWithSpecific(this IVsProject4 project, HierarchyId id, Guid editorType) { Requires.NotNull(project, nameof(project)); Verify.HResult(project.OpenItemWithSpecific(id, 0, ref editorType, "", VSConstants.LOGVIEWID_Primary, (IntPtr)(-1), out IVsWindowFrame frame)); // NOTE: frame is 'null' when opened in an external editor return(frame); }
private static bool GetNatvisFiles(bool solutionLevel, IVsProject4 proj, uint celt, uint[] rgitemids, out uint cActual) { if (solutionLevel) { return(Constants.S_OK == proj.GetFilesEndingWith(".natvis", celt, rgitemids, out cActual)); } else { return(Constants.S_OK == proj.GetFilesWithItemType("natvis", celt, rgitemids, out cActual)); } }
public static void ImplementAddItemWithSpecific(this IVsProject4 project, Func <uint, VSADDITEMOPERATION, string, uint, string[], VSADDRESULT[], int> addItemWithSpecificFunc) { var mock = Mock.Get(project); Guid guidEditorType = Guid.Empty; Guid rguidLogicalView = Guid.Empty; mock.Setup(h => h.AddItemWithSpecific(It.IsAny <uint>(), It.IsAny <VSADDITEMOPERATION>(), It.IsAny <string>(), It.IsAny <uint>(), It.IsAny <string[]>(), It.IsAny <IntPtr>(), It.IsAny <uint>(), ref guidEditorType, It.IsAny <string>(), ref rguidLogicalView, It.IsAny <VSADDRESULT[]>())) .Returns <uint, VSADDITEMOPERATION, string, uint, string[], IntPtr, uint, Guid, string, Guid, VSADDRESULT[]>((itemId, op, itemName, cOpen, arrFiles, handle, flags, editorType, physView, logicalView, result) => { return(addItemWithSpecificFunc(itemId, op, itemName, cOpen, arrFiles, result)); }); }
/// <summary> /// Opens the specified item with the specified editor using the primary logical view. /// </summary> /// <returns> /// The <see cref="IVsWindowFrame"/> that contains the editor; otherwise, <see langword="null"/> if it was opened /// with an editor external of Visual Studio. /// </returns> public static IVsWindowFrame OpenItemWithSpecific(this IVsProject4 project, HierarchyId id, Guid editorType) { Requires.NotNull(project, nameof(project)); IVsWindowFrame frame; HResult hr = project.OpenItemWithSpecific(id, 0, ref editorType, "", VSConstants.LOGVIEWID_Primary, (IntPtr)(-1), out frame); if (hr.Failed) { throw hr.Exception; } // NOTE: frame is 'null' when opened in an external editor return(frame); }
private bool GetNatvisFiles(bool solutionLevel, IVsProject4 proj, uint celt, uint[] rgitemids, out uint cActual) { taskContext.ThrowIfNotOnMainThread(); if (solutionLevel) { return(VSConstants.S_OK == proj.GetFilesEndingWith(".natvis", celt, rgitemids, out cActual)); } else { return(VSConstants.S_OK == proj.GetFilesWithItemType("natvis", celt, rgitemids, out cActual)); } }
public static List <string> GetIceBuilderItems(IVsProject4 project) { List <string> items = new List <String>(); uint sz = 0; project.GetFilesWithItemType("IceBuilder", 0, null, out sz); if (sz > 0) { uint[] ids = new uint[sz]; project.GetFilesWithItemType("IceBuilder", sz, ids, out sz); foreach (uint id in ids) { items.Add(GetItemName(project, id)); } } return(items); }
private void LoadNatvisFromProject(IVsHierarchy hier, List <string> paths, bool solutionLevel) { taskContext.ThrowIfNotOnMainThread(); IVsProject4 proj = hier as IVsProject4; if (proj == null) { return; } // Retrieve up to 10 natvis files in the first pass. This avoids the need to // iterate through the file list a second time if we don't have more than 10 // solution -level natvis files. uint cActual; uint[] itemIds = new uint[10]; if (!GetNatvisFiles(solutionLevel, proj, 10, itemIds, out cActual)) { return; } // If the pre-allocated buffer of 10 natvis files was not enough, reallocate the // buffer and repeat. if (cActual > 10) { itemIds = new uint[cActual]; if (!GetNatvisFiles(solutionLevel, proj, cActual, itemIds, out cActual)) { return; } } // Now, obtain the full path to each of our natvis files and return it. for (uint i = 0; i < cActual; i++) { string document; if (VSConstants.S_OK == proj.GetMkDocument(itemIds[i], out document)) { paths.Add(document); } } }
private static VsContainedLanguageComponentsFactory CreateInstance( IVsProject4 project, IVsContainedLanguageFactory?containedLanguageFactory = null, IVsHierarchy?hierarchy = null, ProjectProperties?properties = null, IActiveWorkspaceProjectContextHost?projectContextHost = null) { var serviceProvider = IOleAsyncServiceProviderFactory.ImplementQueryServiceAsync(containedLanguageFactory, new Guid(LanguageServiceId)); var projectVsServices = new IUnconfiguredProjectVsServicesMock(); projectVsServices.ImplementVsHierarchy(hierarchy); projectVsServices.ImplementVsProject(project); projectVsServices.ImplementThreadingService(IProjectThreadingServiceFactory.Create()); projectVsServices.ImplementActiveConfiguredProjectProperties(properties); return(CreateInstance(serviceProvider, projectVsServices.Object, projectContextHost)); }
private void FindInProjectFast(IVsProject4 vsp4, IVsHierarchy projectHierarchy) { uint celt = 0; uint[] rgItemIds = null; uint pcActual = 0; // // call this method twice, first time is to get the count, second time is to get the data. // VSErrorHandler.ThrowOnFailure(vsp4.GetFilesEndingWith(_input, celt, rgItemIds, out pcActual)); if (pcActual > 0) { // now we know the actual size of the array to allocate, so invoke again celt = pcActual; rgItemIds = new uint[celt]; VSErrorHandler.ThrowOnFailure(vsp4.GetFilesEndingWith(_input, celt, rgItemIds, out pcActual)); Debug.Assert(celt == pcActual, "unexpected number of entries returned from GetFilesEndingWith()"); for (var i = 0; i < celt; i++) { object pvar; // NOTE: in cpp, this property is not the full path. It is the full path in c# & vb projects. var hr = projectHierarchy.GetProperty(rgItemIds[i], (int)__VSHPROPID.VSHPROPID_SaveName, out pvar); var path = pvar as string; if (VSErrorHandler.Succeeded(hr) && path != null) { // Dev10 Bug 653879: Retrieving project item absolute URL is expensive so retrieve when we actually need it. VSFileInfo fileInfo; fileInfo.ItemId = rgItemIds[i]; fileInfo.Path = path; fileInfo.Hierarchy = projectHierarchy; _paths.Add(fileInfo); } } } }
private static bool GetNatvisFiles(bool solutionLevel, IVsProject4 proj, uint celt, uint[] rgitemids, out uint cActual) { if (solutionLevel) { return VSConstants.S_OK == proj.GetFilesEndingWith(".natvis", celt, rgitemids, out cActual); } else { return VSConstants.S_OK == proj.GetFilesWithItemType("natvis", celt, rgitemids, out cActual); } }
private bool ExistInProjectFast(IVsProject4 vsp4) { var pfDoesContain = 0; VSErrorHandler.ThrowOnFailure(vsp4.ContainsFileEndingWith(_input, out pfDoesContain)); return (pfDoesContain != 0); }
public IProjectNode Adapt(IVsProject4 from) { return(CreateNode((IVsHierarchy)from) as IProjectNode); }
private static VsContainedLanguageComponentsFactory CreateInstance(IVsContainedLanguageFactory containedLanguageFactory = null, IVsProject4 project = null, ProjectProperties properties = null, IConfiguredProjectHostObject hostObject = null, ILanguageServiceHost languageServiceHost = null) { var hostProvider = IProjectHostProviderFactory.ImplementActiveIntellisenseProjectHostObject(hostObject); var serviceProvider = IOleAsyncServiceProviderFactory.ImplementQueryServiceAsync(containedLanguageFactory, new Guid(LanguageServiceId)); var projectVsServices = new IUnconfiguredProjectVsServicesMock(); projectVsServices.ImplementVsProject(project); projectVsServices.ImplementThreadingService(IProjectThreadingServiceFactory.Create()); projectVsServices.ImplementActiveConfiguredProjectProperties(properties); return(CreateInstance(serviceProvider, projectVsServices.Object, hostProvider, languageServiceHost)); }
public static List <string> GetIceBuilderItems(IVsProject project) { IVsProject4 project4 = project as IVsProject4; return(project4 != null?GetIceBuilderItems(project4) : GetIceBuilderItems(project as IVsHierarchy)); }