public ProjectInfo(Guid projectGuid, Guid typeGuid, IVsHierarchy hierarchy, string name, string filename) {
     ProjectGuid = projectGuid;
     ProjectType = typeGuid;
     Hierarchy = hierarchy;
     Name = name;
     Filename = filename;
 }
Esempio n. 2
0
        public CSharpProjectShim(
            ICSharpProjectRoot projectRoot,
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt,
            ICommandLineParserService commandLineParserServiceOpt)
            : base(projectTracker,
                   reportExternalErrorCreatorOpt,
                   projectSystemName,
                   hierarchy,
                   LanguageNames.CSharp,
                   serviceProvider,
                   visualStudioWorkspaceOpt,
                   hostDiagnosticUpdateSourceOpt,
                   commandLineParserServiceOpt)
        {
            _projectRoot = projectRoot;
            _warningNumberArrayPointer = Marshal.AllocHGlobal(0);

            // Ensure the default options are set up
            ResetAllOptions();
            UpdateOptions();

            projectTracker.AddProject(this);
        }
        internal PythonLibraryNode(ScopeNode scope, string namePrefix, IVsHierarchy hierarchy, uint itemId)
            : base(scope.Name)
        {
            if (scope is FunctionNode) {
                this.NodeType = LibraryNodeType.Members;
            } else if (scope is ClassNode) {
                this.NodeType = LibraryNodeType.Classes;
                this.Name = string.Format(CultureInfo.InvariantCulture, "{0}{1}", namePrefix, scope.Name);
            }

            this.ownerHierarchy = hierarchy;
            this.fileId = itemId;

            // Now check if we have all the information to navigate to the source location.
            if ((null != ownerHierarchy) && (VSConstants.VSITEMID_NIL != fileId)) {
                if ((0 != Location.Compare(Location.None, scope.Start)) && (0 != Location.Compare(Location.None, scope.End))) {
                    sourceSpan = new TextSpan();
                    sourceSpan.iStartIndex = scope.Start.Column;
                    if (scope.Start.Line > 0) {
                        sourceSpan.iStartLine = scope.Start.Line - 1;
                    }
                    sourceSpan.iEndIndex = scope.End.Column;
                    if (scope.End.Line > 0) {
                        sourceSpan.iEndLine = scope.End.Line - 1;
                    }
                    this.CanGoToSource = true;
                }
            }
        }
 internal EFModelErrorTask(
     string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
     uint itemID)
     : base(document, errorMessage, lineNumber, columnNumber, category, hierarchy, itemID)
 {
     Navigate += EFModelErrorTaskNavigator.NavigateTo;
 }
        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;
        }
Esempio n. 6
0
            public HierarchyListener(IVsHierarchy hierarchy, LibraryManager manager) {
                Utilities.ArgumentNotNull("hierarchy", hierarchy);
                Utilities.ArgumentNotNull("manager", manager);

                _hierarchy = hierarchy;
                _manager = manager;
            }
 public NodejsUwpProjectFlavorCfg(NodejsUwpProjectFlavor baseProjectNode, IVsCfg baseConfiguration, IVsProjectFlavorCfg innerConfiguration)
 {
     _baseCfg = baseConfiguration;
     _innerCfg = innerConfiguration;
     project = baseProjectNode;
     mapIVsCfgToNodejsUwpProjectFlavorCfg.Add(baseConfiguration, this);
 }
        public override int OnAfterOpenProject(IVsHierarchy hierarchy, int added)
        {
            // If this is a new project and our project. We use here that it is only our project that will implemnet the "internal"  IBuildDependencyOnProjectContainer.
            if(added != 0 && hierarchy is IBuildDependencyUpdate)
            {
                IVsUIHierarchy uiHierarchy = hierarchy as IVsUIHierarchy;
                Debug.Assert(uiHierarchy != null, "The ProjectNode should implement IVsUIHierarchy");
                // Expand and select project node
                IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ServiceProvider, HierarchyNode.SolutionExplorer);
                if(uiWindow != null)
                {
                    __VSHIERARCHYITEMSTATE state;
                    uint stateAsInt;
                    if(uiWindow.GetItemState(uiHierarchy, VSConstants.VSITEMID_ROOT, (uint)__VSHIERARCHYITEMSTATE.HIS_Expanded, out stateAsInt) == VSConstants.S_OK)
                    {
                        state = (__VSHIERARCHYITEMSTATE)stateAsInt;
                        if(state != __VSHIERARCHYITEMSTATE.HIS_Expanded)
                        {
                            int hr;
                            hr = uiWindow.ExpandItem(uiHierarchy, VSConstants.VSITEMID_ROOT, EXPANDFLAGS.EXPF_ExpandParentsToShowItem);
                            if(ErrorHandler.Failed(hr))
                                Trace.WriteLine("Failed to expand project node");
                            hr = uiWindow.ExpandItem(uiHierarchy, VSConstants.VSITEMID_ROOT, EXPANDFLAGS.EXPF_SelectItem);
                            if(ErrorHandler.Failed(hr))
                                Trace.WriteLine("Failed to select project node");

                            return hr;
                        }
                    }
                }
            }
            return VSConstants.S_OK;
        }
Esempio n. 9
0
 public static Project GetProject(IVsHierarchy hierarchy)
 {
     object project;
     ErrorHandler.ThrowOnFailure(
         hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out project));
     return (Project)project;
 }
Esempio n. 10
0
 // internal for testing purposes only.
 internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, IVsHierarchy hierarchy, string projectDisplayName, string projectFilePath, Guid projectGuid, string language, ICommandLineParserService commandLineParserService, string binOutputPath)
 {
     return new CPSProject(projectTracker, reportExternalErrorCreatorOpt: null, hierarchy: hierarchy, language: language,
         serviceProvider: serviceProvider, visualStudioWorkspaceOpt: null, hostDiagnosticUpdateSourceOpt: null,
         projectDisplayName: projectDisplayName, projectFilePath: projectFilePath, projectGuid: projectGuid,
         binOutputPath: binOutputPath, commandLineParserServiceOpt: commandLineParserService);
 }
 protected CommonLibraryNode(CommonLibraryNode node) :
     base(node) {
     _fileId = node._fileId;
     _ownerHierarchy = node._ownerHierarchy;
     _fileMoniker = node._fileMoniker;
     _sourceSpan = node._sourceSpan;
 }
        int IVsPersistSolutionProps.WriteSolutionProps(IVsHierarchy pHierarchy, string pszKey, IPropertyBag pPropBag)
        {
            if (pHierarchy != null)
                return VSConstants.S_OK; // Not send by our code!
            else if(pPropBag == null)
                return VSConstants.E_POINTER;

            // This method is called from the VS implementation after a request from SaveSolutionProps

            ISccSettingsStore translate = GetService<ISccSettingsStore>();
            IVisualGitSccService scc = GetService<IVisualGitSccService>();

            using (IPropertyMap map = translate.GetMap(pPropBag))
            {
                switch (pszKey)
                {
                    case GitPropertyCategory:
                        map.SetRawValue(ManagedPropertyName, true.ToString());
                        // BH: Don't localize this text! Changing it will change all solutions marked as managed by VisualGit
                        map.SetRawValue(ManagerPropertyName, "VisualGit - Git Support for Visual Studio");

                        scc.WriteSolutionProperties(map);
                        break;
                    case VisualGitId.SccStructureName:
                        translate.WriteSolutionProperties(map);
                        break;
                }
            }

            return VSConstants.S_OK;
        }
        public static object GetPropertyValue(int propid, uint itemId, IVsHierarchy vsHierarchy)
        {
            if (itemId == VSConstants.VSITEMID_NIL)
            {
                return null;
            }

            try
            {
                object o;
                ErrorHandler.ThrowOnFailure(vsHierarchy.GetProperty(itemId, propid, out o));

                return o;
            }
            catch (System.NotImplementedException)
            {
                return null;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                return null;
            }
            catch (System.ArgumentException)
            {
                return null;
            }
        }
        public int OnAfterLastDocumentUnlock(IVsHierarchy pHier, uint itemid, string pszMkDocument, int fClosedWithoutSaving)
        {
            //The close initiated in OnAfterSave will cause an additional call here for the .diagram file.
            if (EDMXFileTools.EdmxTools.RefreshOnSaveEnabled && !String.IsNullOrEmpty(closingDocument))
            {
                if (pszMkDocument.Equals(closingDocument))
                {
                    try
                    {
                        DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;

                        //Now the file is closed we need to iterate to find it.
                        foreach (Project proj in dte.Solution.Projects)
                        {
                            foreach (ProjectItem item in proj.ProjectItems)
                            {
                                if (item.FileNames[0].Equals(closingDocument))
                                {
                                    if (!item.IsOpen)
                                        item.Open().Activate();
                                    closingDocument = String.Empty;
                                    return VSConstants.S_OK;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(String.Format("EdmxFileTools Error reactivating {0}, {1}", closingDocument, ex.Message));
                    }
                }
            }
            return VSConstants.S_OK;
        }
 public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     uint cookie;
     pHierarchy.AdviseHierarchyEvents(new ProjectEventSink(pHierarchy), out cookie);
     projectCookies[pHierarchy] = cookie;
     return 0;
 }
Esempio n. 16
0
 /// <summary>
 /// Retrieves or creates a node provider for a buffer
 /// </summary>
 /// <param name="buffer"></param>
 /// <returns></returns>
 internal NodeProvider GetNodeProvider(ITextBuffer buffer, IVsHierarchy hier, string filename)
 {
     var provider = new NodeProvider(this, filename, type_resolver);
     buffer.Properties.AddProperty(typeof(NodeProvider), provider);
     template_loader.Register(filename, buffer, provider);
     return provider;
 }
Esempio n. 17
0
        public CPSProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectDisplayName,
            string projectFilePath,
            IVsHierarchy hierarchy,
            string language,
            Guid projectGuid,
            string commandLineForOptions,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt,
            ICommandLineParserService commandLineParserServiceOpt)
            : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath,
                   hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt)
        {
            // Initialize the options.
            SetCommandLineArguments(commandLineForOptions);

            // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker.
            // If we were unable to set the output path from SetCommandLineArguments (due to null output file name or directory in the given commandLineForOptions),
            // we set a default unique output path.
            if (this.TryGetBinOutputPath() == null)
            {
                var uniqueDefaultOutputPath = PathUtilities.CombinePathsUnchecked(Path.GetTempPath(), projectDisplayName + projectGuid.GetHashCode().ToString());
                SetOutputPathAndRelatedData(objOutputPath: uniqueDefaultOutputPath, hasSameBinAndObjOutputPaths: true);
            }

            Contract.ThrowIfNull(this.TryGetBinOutputPath());

            // Now hook up the project to the project tracker.
            projectTracker.AddProject(this);

            _lastDesignTimeBuildSucceeded = true;
        }
Esempio n. 18
0
 private void DoesItemMatch(IVsHierarchy item, uint id, VsProjectItemPath projectItemPath)
 {
     if (DoItemNamesComparison(_input, projectItemPath))
     {
         _foundMatch = true;
     }
 }
 public int OnRetargetingBeforeChange(string projRef, IVsHierarchy pBeforeChangeHier, string currentTargetFramework,
     string newTargetFramework, out bool pCanceled, out string ppReasonMsg)
 {
     pCanceled = false;
     ppReasonMsg = "";
     return VSConstants.S_OK;
 }
Esempio n. 20
0
        /// <summary>
        /// Used by the editor factory to create an editor instance. the environment first determines the 
        /// editor factory with the highest priority for opening the file and then calls 
        /// IVsEditorFactory.CreateEditorInstance. If the environment is unable to instantiate the document data 
        /// in that editor, it will find the editor with the next highest priority and attempt to so that same 
        /// thing. 
        /// NOTE: The priority of our editor is 32 as mentioned in the attributes on the package class.
        /// 
        /// Since our editor supports opening only a single view for an instance of the document data, if we 
        /// are requested to open document data that is already instantiated in another editor, or even our 
        /// editor, we return a value VS_E_INCOMPATIBLEDOCDATA.
        /// </summary>
        /// <param name="grfCreateDoc">Flags determining when to create the editor. Only open and silent flags 
        /// are valid
        /// </param>
        /// <param name="pszMkDocument">path to the file to be opened</param>
        /// <param name="pszPhysicalView">name of the physical view</param>
        /// <param name="pvHier">pointer to the IVsHierarchy interface</param>
        /// <param name="itemid">Item identifier of this editor instance</param>
        /// <param name="punkDocDataExisting">This parameter is used to determine if a document buffer 
        /// (DocData object) has already been created
        /// </param>
        /// <param name="ppunkDocView">Pointer to the IUnknown interface for the DocView object</param>
        /// <param name="ppunkDocData">Pointer to the IUnknown interface for the DocData object</param>
        /// <param name="pbstrEditorCaption">Caption mentioned by the editor for the doc window</param>
        /// <param name="pguidCmdUI">the Command UI Guid. Any UI element that is visible in the editor has 
        /// to use this GUID. This is specified in the .vsct file
        /// </param>
        /// <param name="pgrfCDW">Flags for CreateDocumentWindow</param>
        /// <returns></returns>
        public int CreateEditorInstance(uint grfCreateDoc, string pszMkDocument, string pszPhysicalView, IVsHierarchy pvHier, uint itemid, IntPtr punkDocDataExisting, out IntPtr ppunkDocView, out IntPtr ppunkDocData, out string pbstrEditorCaption, out Guid pguidCmdUI, out int pgrfCDW)
        {
            // Initialize to null
            ppunkDocView = IntPtr.Zero;
            ppunkDocData = IntPtr.Zero;
            pguidCmdUI = GuidList.ConfigModuleEditorFactory;
            pgrfCDW = 0;
            pbstrEditorCaption = null;

            // Validate inputs
            if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
            {
                return VSConstants.E_INVALIDARG;
            }
            if (punkDocDataExisting != IntPtr.Zero)
            {
                return VSConstants.VS_E_INCOMPATIBLEDOCDATA;
            }

            // Create the Document (editor)
            ConfigModuleEditorPane editor = new ConfigModuleEditorPane();
            ppunkDocView = Marshal.GetIUnknownForObject(editor);
            ppunkDocData = Marshal.GetIUnknownForObject(editor);
            pbstrEditorCaption = "";

            return VSConstants.S_OK;
        }
Esempio n. 21
0
		public static IEnumerable<string> GetProjectItems(IVsHierarchy project, uint itemId)
		{

            // Don't enumerate over nodes that have side effects
            // This is to prevent errors that could occur since the side affect code can do things like try to
            // connect to a db
            object hasSideEffects = GetPropertyValue((int)__VSHPROPID.VSHPROPID_HasEnumerationSideEffects, itemId, project);
		    if (hasSideEffects != null && ((bool) hasSideEffects))
		    {
		        yield break;
		    }

			object pVar = GetPropertyValue((int)__VSHPROPID.VSHPROPID_FirstChild, itemId, project);

			uint childId = GetItemId(pVar);
			while (childId != VSConstants.VSITEMID_NIL)
			{
				string childPath = GetCanonicalName(childId, project);
				yield return childPath;

				foreach (var childNodePath in GetProjectItems(project, childId)) yield return childNodePath;

				pVar = GetPropertyValue((int)__VSHPROPID.VSHPROPID_NextSibling, childId, project);
				childId = GetItemId(pVar);
			}
		}
Esempio n. 22
0
        public static string GetCanonicalName(uint itemId, IVsHierarchy hierarchy)
        {
            string strRet = string.Empty;
            int hr = hierarchy.GetCanonicalName(itemId, out strRet);

            if (hr == VSConstants.E_NOTIMPL)
            {
                // Special case E_NOTIMLP to avoid perf hit to throw an exception.
                return string.Empty;
            }
            else
            {
                try
                {
                    ErrorHandler.ThrowOnFailure(hr);
                }
                catch (System.Runtime.InteropServices.COMException)
                {
                    strRet = string.Empty;
                }

                // This could be in the case of S_OK, S_FALSE, etc.
                return strRet;
            }
        }
        private static bool IsSingleProjectItemSelection(this OleMenuCommand command, out IVsHierarchy hierarchy, out uint itemid)
        {
            hierarchy = null;
            itemid = VSConstants.VSITEMID_NIL;
            int hr = VSConstants.S_OK;

            var monitorSelection = Package.GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
            var solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
            if (monitorSelection == null || solution == null)
            {
                return false;
            }

            IVsMultiItemSelect multiItemSelect = null;
            IntPtr hierarchyPtr = IntPtr.Zero;
            IntPtr selectionContainerPtr = IntPtr.Zero;

            try
            {
                hr = monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainerPtr);

                if (ErrorHandler.Failed(hr) || hierarchyPtr == IntPtr.Zero || itemid == VSConstants.VSITEMID_NIL)
                {
                    // there is no selection
                    return false;
                }

                // multiple items are selected
                if (multiItemSelect != null) return false;

                // there is a hierarchy root node selected, thus it is not a single item inside a project

                if (itemid == VSConstants.VSITEMID_ROOT) return false;

                hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
                if (hierarchy == null) return false;

                Guid guidProjectID = Guid.Empty;

                if (ErrorHandler.Failed(solution.GetGuidOfProject(hierarchy, out guidProjectID)))
                {
                    return false; // hierarchy is not a project inside the Solution if it does not have a ProjectID Guid
                }

                // if we got this far then there is a single project item selected
                return true;
            }
            finally
            {
                if (selectionContainerPtr != IntPtr.Zero)
                {
                    Marshal.Release(selectionContainerPtr);
                }

                if (hierarchyPtr != IntPtr.Zero)
                {
                    Marshal.Release(hierarchyPtr);
                }
            }
        }
Esempio n. 24
0
 int IVsSolutionEvents.OnQueryUnloadProject(IVsHierarchy pRealHierarchy, ref int pfCancel)
 {
     var project = VsxHelper.GetProject(pRealHierarchy);
     if (project != null)
         OnQueryUnloadProject(project);
     return VSConstants.S_OK;
 }
Esempio n. 25
0
 public int CreateEditorInstance(
     uint grfCreateDoc,
     string pszMkDocument,
     string pszPhysicalView,
     IVsHierarchy pvHier,
     uint itemid,
     IntPtr punkDocDataExisting,
     out IntPtr ppunkDocView,
     out IntPtr ppunkDocData,
     out string pbstrEditorCaption,
     out Guid pguidCmdUI,
     out int pgrfCdw)
 {
     ppunkDocView = IntPtr.Zero;
     ppunkDocData = IntPtr.Zero;
     pguidCmdUI = GetType().GUID;
     pgrfCdw = 0;
     pbstrEditorCaption = null;
     if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
         return VSConstants.E_INVALIDARG;
     if (punkDocDataExisting != IntPtr.Zero)
         return VSConstants.VS_E_INCOMPATIBLEDOCDATA;
     EditorPane newEditor = new EditorPane(_vsPackage);
     ppunkDocView = Marshal.GetIUnknownForObject(newEditor);
     ppunkDocData = Marshal.GetIUnknownForObject(newEditor);
     pbstrEditorCaption = "";
     return VSConstants.S_OK;
 }
Esempio n. 26
0
        public AbstractLegacyProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            string language,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt,
            ICommandLineParserService commandLineParserServiceOpt = null)
            : base(projectTracker,
                  reportExternalErrorCreatorOpt,
                  projectSystemName,
                  projectFilePath: GetProjectFilePath(hierarchy),
                  hierarchy: hierarchy,
                  projectGuid: GetProjectIDGuid(hierarchy),
                  language: language,
                  serviceProvider: serviceProvider,
                  visualStudioWorkspaceOpt: visualStudioWorkspaceOpt,
                  hostDiagnosticUpdateSourceOpt: hostDiagnosticUpdateSourceOpt,
                  commandLineParserServiceOpt: commandLineParserServiceOpt)
        {
            if (Hierarchy != null)
            {
                ConnectHierarchyEvents();
                this.IsWebSite = GetIsWebsiteProject(Hierarchy);
            }

            // Initialize command line arguments.
            base.SetArguments(commandLine: string.Empty);
        }
Esempio n. 27
0
        private static bool TryGetOutputPathFromHierarchy(IVsHierarchy hierarchy, string containingDirectoryPathOpt, out string binOutputPath)
        {
            binOutputPath = null;
            var storage = hierarchy as IVsBuildPropertyStorage;
            if (storage == null)
            {
                return false;
            }

            if (ErrorHandler.Failed(storage.GetPropertyValue("OutDir", null, (uint)_PersistStorageType.PST_PROJECT_FILE, out var outputDirectory)) ||
                ErrorHandler.Failed(storage.GetPropertyValue("TargetFileName", null, (uint)_PersistStorageType.PST_PROJECT_FILE, out var targetFileName)))
            {
                return false;
            }

            // web app case
            if (!PathUtilities.IsAbsolute(outputDirectory))
            {
                if (containingDirectoryPathOpt == null)
                {
                    return false;
                }

                outputDirectory = FileUtilities.ResolveRelativePath(outputDirectory, containingDirectoryPathOpt);
            }

            binOutputPath = FileUtilities.NormalizeAbsolutePath(Path.Combine(outputDirectory, targetFileName));
            return true;
        }
        int IVsUpdateSolutionEvents2.UpdateProjectCfg_Begin(
            IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg pCfgSln, uint dwAction, ref int pfCancel)
        {
            //
            //   if clean project or solution,   dwAction == 0x100000
            //   if build project or solution,   dwAction == 0x010000
            //   if rebuild project or solution, dwAction == 0x410000
            //
            if (dwAction == 0x010000
                || dwAction == 0x410000)
            {
                var validationSuccessful =
                    VisualStudioEdmxValidator.LoadAndValidateAllFilesInProject(
                        pHierProj, /*doEscherValidation*/ false, ShouldValidateArtifactDuringBuild);

                // we cause a 'build break' for command-line builds by setting PfCancel = 1
                if (PackageManager.Package.IsBuildingFromCommandLine
                    && !validationSuccessful)
                {
                    pfCancel = 1;
                }
            }

            return VSConstants.S_OK;
        }
Esempio n. 29
0
 public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
 {
     var project = pHierarchy as IProjectManager;
     if (project != null)
         project.FixupProject();
     return VSConstants.S_OK;
 }
 public HierarchyListener(IVsHierarchy hierarchy)
 {
     if (null == hierarchy) {
         throw new ArgumentNullException("hierarchy");
     }
     this.hierarchy = hierarchy;
 }
 public static Project GetProject(this IVsHierarchy hierarchy)
 {
     return(hierarchy.GetProperty <Project>((int)__VSHPROPID.VSHPROPID_ExtObject));
 }
Esempio n. 32
0
 public virtual int OnAfterOpenProject(IVsHierarchy hierarchy, int added)
 {
     return(VSConstants.E_NOTIMPL);
 }
 public int OnActiveProjectCfgChange(IVsHierarchy pIVsHierarchy)
 {
     return(VSConstants.S_OK);
 }
 public static string GetDisplayName(this IVsHierarchy hierarchy)
 {
     return(hierarchy.GetProperty <string>((int)__VSHPROPID.VSHPROPID_Caption));
 }
 public static string GetName(this IVsHierarchy hierarchy)
 {
     return(hierarchy.GetProperty <string>((int)__VSHPROPID.VSHPROPID_Name));
 }
 public static string GetProjectDir(this IVsHierarchy hierarchy)
 {
     return(hierarchy.GetProperty <string>((int)__VSHPROPID.VSHPROPID_ProjectDir));
 }
 /// <summary>
 /// Returns true if the hierachy object is a Common ProjectSystem object.
 /// see: https://github.com/dotnet/project-system
 /// </summary>
 public static bool IsCpsProject(this IVsHierarchy hierarchy)
 {
     // see: https://github.com/Microsoft/VSProjectSystem/blob/master/doc/automation/detect_whether_a_project_is_a_CPS_project.md
     return(hierarchy.IsCapabilityMatch("CPS"));
 }
 int IVsPersistDocData.RenameDocData(uint grfAttribs, IVsHierarchy pHierNew, uint itemidNew, string pszMkDocumentNew)
 {
     return(VSConstants.E_NOTIMPL);
 }
Esempio n. 39
0
        /// <summary>
        /// Shows a preview of the transformation in a temporary file.
        /// </summary>
        /// <param name="hier">Current IVsHierarchy</param>
        /// <param name="sourceFile">Full path to the file to be trasnformed</param>
        /// <param name="transformFile">Full path to the transformation file</param>
        private void PreviewTransform(IVsHierarchy hier, string sourceFile, string transformFile)
        {
            if (string.IsNullOrWhiteSpace(sourceFile))
            {
                throw new ArgumentNullException(nameof(sourceFile));
            }

            if (string.IsNullOrWhiteSpace(transformFile))
            {
                throw new ArgumentNullException(nameof(transformFile));
            }

            if (!File.Exists(sourceFile))
            {
                throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.Error_SourceFileNotFound, sourceFile), sourceFile);
            }

            if (!File.Exists(transformFile))
            {
                throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.Error_TransformFileNotFound, transformFile), transformFile);
            }

            // Get our options
            using (OptionsDialogPage optionsPage = new OptionsDialogPage())
                using (AdvancedOptionsDialogPage advancedOptionsPage = new AdvancedOptionsDialogPage())
                {
                    optionsPage.LoadSettingsFromStorage();
                    advancedOptionsPage.LoadSettingsFromStorage();

                    this.LogMessageWriteLineFormat("SlowCheetah PreviewTransform");
                    FileInfo sourceFileInfo = new FileInfo(sourceFile);

                    // dest file
                    string destFile = PackageUtilities.GetTempFilename(true, sourceFileInfo.Extension);
                    this.TempFilesCreated.Add(destFile);

                    // perform the transform and then display the result into the diffmerge tool that comes with VS.
                    // If for some reason we can't find it, we just open it in an editor window
                    this.errorListProvider.Tasks.Clear();
                    ITransformationLogger logger      = new TransformationPreviewLogger(this.errorListProvider, hier);
                    ITransformer          transformer = new XmlTransformer(logger, false);
                    if (!transformer.Transform(sourceFile, transformFile, destFile))
                    {
                        throw new TransformFailedException(Resources.Resources.TransformPreview_ErrorMessage);
                    }

                    // Does the customer want a preview?
                    if (optionsPage.EnablePreview == false)
                    {
                        ProjectUtilities.GetDTE().ItemOperations.OpenFile(destFile);
                    }
                    else
                    {
                        // If the diffmerge service is available (dev11) and no diff tool is specified, or diffmerge.exe is specifed we use the service
                        if (this.GetService(typeof(SVsDifferenceService)) is IVsDifferenceService diffService && (!File.Exists(advancedOptionsPage.PreviewToolExecutablePath) || advancedOptionsPage.PreviewToolExecutablePath.EndsWith("diffmerge.exe", StringComparison.OrdinalIgnoreCase)))
                        {
                            if (!string.IsNullOrEmpty(advancedOptionsPage.PreviewToolExecutablePath) && !File.Exists(advancedOptionsPage.PreviewToolExecutablePath))
                            {
                                logger.LogWarning(string.Format(Resources.Resources.Error_CantFindPreviewTool, advancedOptionsPage.PreviewToolExecutablePath));
                            }

                            string sourceName = Path.GetFileName(sourceFile);
                            string leftLabel  = string.Format(CultureInfo.CurrentCulture, Resources.Resources.TransformPreview_LeftLabel, sourceName);
                            string rightLabel = string.Format(CultureInfo.CurrentCulture, Resources.Resources.TransformPreview_RightLabel, sourceName, Path.GetFileName(transformFile));
                            string caption    = string.Format(CultureInfo.CurrentCulture, Resources.Resources.TransformPreview_Caption, sourceName);
                            string tooltip    = string.Format(CultureInfo.CurrentCulture, Resources.Resources.TransformPreview_ToolTip, sourceName);
                            diffService.OpenComparisonWindow2(sourceFile, destFile, caption, tooltip, leftLabel, rightLabel, null, null, (uint)__VSDIFFSERVICEOPTIONS.VSDIFFOPT_RightFileIsTemporary);
                        }
Esempio n. 40
0
 public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew)
 {
     return(VSConstants.S_OK);
 }
 public int OnQueryUnloadProject(IVsHierarchy pRealHierarchy, ref int pfCancel)
 {
     return(VSConstants.S_OK);
 }
 int IVsPersistDocData.OnRegisterDocData(uint docCookie, IVsHierarchy pHierNew, uint itemidNew)
 {
     return(VSConstants.S_OK);
 }
 public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
 {
     return(VSConstants.S_OK);
 }
 public int OnBeforeUnloadProject(IVsHierarchy pRealHierarchy, IVsHierarchy pStubHierarchy)
 {
     return(VSConstants.S_OK);
 }
 public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     return(VSConstants.S_OK);
 }
 public int OnAfterLoadProject(IVsHierarchy pStubHierarchy, IVsHierarchy pRealHierarchy)
 {
     return(VSConstants.S_OK);
 }
 public int get_StartupProject(out IVsHierarchy ppHierarchy)
 {
     throw new NotImplementedException();
 }
 public int OnQueryCloseProject(IVsHierarchy pHierarchy, int fRemoving, ref int pfCancel)
 {
     return(VSConstants.S_OK);
 }
 public int GetProjectDependencies(IVsHierarchy pHier, uint celt, IVsHierarchy[] rgpHier, uint[] pcActual = null)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Capability inferring that the project uses project.json to manage its source items.
 /// https://github.com/Microsoft/VSProjectSystem/blob/master/doc/overview/project_capabilities.md.
 /// </summary>
 private static bool IsDnxProject(this IVsHierarchy project)
 {
     return(!project.IsCapabilityMatch(ProjectCapabilities.DeclaredSourceItems));
 }
        public bool AddSuppressions(bool selectedErrorListEntriesOnly, bool suppressInSource, IVsHierarchy projectHierarchyOpt)
        {
            if (_tableControl == null)
            {
                return(false);
            }

            Func <Project, bool> shouldFixInProject = GetShouldFixInProjectDelegate(_workspace, projectHierarchyOpt);

            return(ApplySuppressionFix(shouldFixInProject, selectedErrorListEntriesOnly, isAddSuppression: true, isSuppressionInSource: suppressInSource, onlyCompilerDiagnostics: false, showPreviewChangesDialog: true));
        }
 public int StartSimpleUpdateProjectConfiguration(IVsHierarchy pIVsHierarchyToBuild, IVsHierarchy pIVsHierarchyDependent, string pszDependentConfigurationCanonicalName, uint dwFlags, uint dwDefQueryResults, int fSuppressUI)
 {
     throw new NotImplementedException();
 }
 public VsCodeDomLoader(DesignerLoader loader, IVsHierarchy hier, int itemid, CodeDomProvider provider, TextBuffer buffer, IDesignerLoaderHost host) : base(loader, provider, buffer, host)
 {
     this.vsHierarchy = hier;
     this.itemid      = itemid;
 }
 public int FindActiveProjectCfg(IntPtr pvReserved1, IntPtr pvReserved2, IVsHierarchy pIVsHierarchy_RequestedProject, IVsProjectCfg[] ppIVsProjectCfg_Active = null)
 {
     throw new NotImplementedException();
 }
Esempio n. 55
0
 int IVsSolutionEvents.OnQueryCloseProject(IVsHierarchy pHierarchy, int fRemoving, ref int pfCancel)
 {
     return(VSConstants.S_OK);
 }
 private static Func <Project, bool> GetShouldFixInProjectDelegate(VisualStudioWorkspaceImpl workspace, IVsHierarchy projectHierarchyOpt)
 {
     if (projectHierarchyOpt == null)
     {
         return(p => true);
     }
     else
     {
         var projectIdsForHierarchy = workspace.ProjectTracker.Projects
                                      .Where(p => p.Language == LanguageNames.CSharp || p.Language == LanguageNames.VisualBasic)
                                      .Where(p => p.Hierarchy == projectHierarchyOpt)
                                      .Select(p => workspace.CurrentSolution.GetProject(p.Id).Id)
                                      .ToImmutableHashSet();
         return(p => projectIdsForHierarchy.Contains(p.Id));
     }
 }
Esempio n. 57
0
        int IVsSolutionEvents.OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
        {
            BeforeCloseProject?.Invoke(this, new ParamEventArgs(pHierarchy, fRemoved));

            return(VSConstants.S_OK);
        }
Esempio n. 58
0
 int IVsSolutionEvents.OnQueryUnloadProject(IVsHierarchy pRealHierarchy, ref int pfCancel)
 {
     return(VSConstants.S_OK);
 }
Esempio n. 59
0
 int IVsSolutionEvents.OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     return(VSConstants.S_OK);
 }
Esempio n. 60
0
        int IVsSolutionEvents.OnBeforeUnloadProject(IVsHierarchy pRealHierarchy, IVsHierarchy pStubHierarchy)
        {
            BeforeUnloadProject?.Invoke(this, new ParamEventArgs(pRealHierarchy, pStubHierarchy));

            return(VSConstants.S_OK);
        }