示例#1
0
        /// <summary>
        /// Constructor to create a new MSBuild.BuildItem and add it to the project
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        internal ProjectElement(ProjectNode project, string itemPath, string itemType)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (String.IsNullOrEmpty(itemPath))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemPath");
            }

            if (String.IsNullOrEmpty(itemType))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemType");
            }

            this.itemProject = project;

            // create and add the item to the project

            this.item = project.BuildProject.AddNewItem(itemType, Microsoft.Build.BuildEngine.Utilities.Escape(itemPath));
            this.itemProject.SetProjectFileDirty(true);
            this.RefreshProperties();
        }
示例#2
0
        /// <summary>
        /// Constructor for the ReferenceNode. It is called when the project is reloaded, when the project element representing the refernce exists. 
        /// </summary>
        public ProjectReferenceNode(ProjectNode root, ProjectElement element)
            : base(root, element)
        {
            this.referencedProjectRelativePath = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
            Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectRelativePath), "Could not retrive referenced project path form project file");

            string guidString = this.ItemNode.GetMetadata(ProjectFileConstants.Project);

            // Continue even if project setttings cannot be read.
            try
            {
                this.referencedProjectGuid = new Guid(guidString);

                this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid);
                this.ProjectMgr.AddBuildDependency(this.buildDependency);
            }
            finally
            {
                Debug.Assert(this.referencedProjectGuid != Guid.Empty, "Could not retrive referenced project guidproject file");

                this.ReferencedProjectName = this.ItemNode.GetMetadata(ProjectFileConstants.Name);

                Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectName), "Could not retrive referenced project name form project file");
            }

            Uri uri = new Uri(this.ProjectMgr.BaseURI.Uri, this.referencedProjectRelativePath);

            if (uri != null)
            {
                this.referencedProjectFullPath = Microsoft.VisualStudio.Shell.Url.Unescape(uri.LocalPath, true);
            }
        }
示例#3
0
 /// <summary>
 /// Constructor for the AssemblyReferenceNode
 /// </summary>
 public AssemblyReferenceNode(ProjectNode root, string assemblyPath)
     : base(root)
 {
     // Validate the input parameters.
     if (null == root)
     {
         throw new ArgumentNullException("root");
     }
     if (string.IsNullOrEmpty(assemblyPath))
     {
         throw new ArgumentNullException("assemblyPath");
     }
     // The assemblyPath variable can be an actual path on disk or a generic assembly name.
     if (File.Exists(assemblyPath))
     {
         // The assemblyPath parameter is an actual file on disk; try to load it.
         this.assemblyName = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath);
         this.assemblyPath = assemblyPath;
     }
     else
     {
         // The file does not exist on disk. This can be because the file / path is not
         // correct or because this is not a path, but an assembly name.
         // Try to resolve the reference as an assembly name.
         CreateFromAssemblyName(new System.Reflection.AssemblyName(assemblyPath));
     }
 }
示例#4
0
        /// <summary>
        /// Constructor to create a new MSBuild.ProjectItem and add it to the project
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        internal ProjectElement(ProjectNode project, string itemPath, string itemType)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (String.IsNullOrEmpty(itemPath))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemPath");
            }

            if (String.IsNullOrEmpty(itemType))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemType");
            }

            this.itemProject = project;

            // create and add the item to the project
            DoAdd(itemType, itemPath);
            CheckAndTryToFixWildcards(itemType, itemPath);

            this.itemProject.SetProjectFileDirty(true);
            this.RefreshProperties();
        }
        /// <summary>
        /// Overloaded constructor for creating a ComReferenceNode from selector data
        /// </summary>
        /// <param name="root">The Project node</param>
        /// <param name="selectorData">The component selctor data.</param>
        public ComReferenceNode(ProjectNode root, VSCOMPONENTSELECTORDATA selectorData)
            : base(root)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }
            if (selectorData.type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project
                || selectorData.type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus)
            {
                throw new ArgumentException();
            }

            // Initialize private state
            this.typeName = selectorData.bstrTitle;
            this.typeGuid = selectorData.guidTypeLibrary;
            this.majorVersionNumber = selectorData.wTypeLibraryMajorVersion.ToString(CultureInfo.InvariantCulture);
            this.minorVersionNumber = selectorData.wTypeLibraryMinorVersion.ToString(CultureInfo.InvariantCulture);
            this.lcid = selectorData.lcidTypeLibrary.ToString(CultureInfo.InvariantCulture);

            // Check to see if the COM object actually exists.
            this.SetInstalledFilePath();
            // If the value cannot be set throw.
            if (String.IsNullOrEmpty(this.installedFilePath))
            {
                throw new ArgumentException();
            }
        }
        /// <summary>
        /// Constructor for the AssemblyReferenceNode
        /// </summary>
        public AssemblyReferenceNode(ProjectNode root, string assemblyPath)
            : base(root)
        {
            // Validate the input parameters.
            if (null == root)
            {
                throw new ArgumentNullException("root");
            }
            if (string.IsNullOrEmpty(assemblyPath))
            {
                throw new ArgumentNullException("assemblyPath");
            }

            this.InitializeFileChangeEvents();

            // The assemblyPath variable can be an actual path on disk or a generic assembly name.
            if (File.Exists(assemblyPath))
            {
                // The assemblyPath parameter is an actual file on disk; try to load it.
                this.assemblyName = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath);
                this.assemblyPath = assemblyPath;

                // We register with listeningto chnages onteh path here. The rest of teh cases will call into resolving the assembly and registration is done there.
                this.fileChangeListener.ObserveItem(this.assemblyPath);
            }
            else
            {
                // The file does not exist on disk. This can be because the file / path is not
                // correct or because this is not a path, but an assembly name.
                // Try to resolve the reference as an assembly name.
                this.CreateFromAssemblyName(new System.Reflection.AssemblyName(assemblyPath));
            }
        }
示例#7
0
        /// <summary>
        /// Constructor for the ReferenceNode
        /// </summary>
        public AssemblyReferenceNode(ProjectNode root, ProjectElement e)
            : base(root, e)
        {
            this.GetPathNameFromProjectFile();

            string include = this.ItemNode.GetMetadata(ProjectFileConstants.Include);

            CreateFromAssemblyName(new System.Reflection.AssemblyName(include));
        }
示例#8
0
文件: output.cs 项目: zooba/wix3
        /// <summary>
        /// Constructor for IVSOutput2 implementation
        /// </summary>
        /// <param name="projectManager">Project that produce this output</param>
        /// <param name="configuration">Configuration that produce this output</param>
        /// <param name="outputAssembly">MSBuild generated item corresponding to the output assembly (by default, these would be of type MainAssembly</param>
        public Output(ProjectNode projectManager, MSBuildExecution.ProjectItemInstance outputAssembly)
        {
            if (projectManager == null)
                throw new ArgumentNullException("projectManager");
            if (outputAssembly == null)
                throw new ArgumentNullException("outputAssembly");

            project = projectManager;
            output = outputAssembly;
        }
示例#9
0
        /// <summary>
        /// Constructor to create a new MSBuild.BuildItem and add it to the project
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        internal ProjectElement(ProjectNode project, string itemPath, string itemType)
        {
            if (project == null)
                throw new ArgumentNullException("project", String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.AddToNullProjectError), itemPath));

            itemProject = project;

            // create and add the item to the project
            item = project.BuildProject.AddNewItem(itemType, itemPath);
            project.SetProjectFileDirty(true);
            this.RefreshProperties();
        }
示例#10
0
文件: output.cs 项目: Jeremiahf/wix3
        /// <summary>
        /// Constructor for IVSOutput2 implementation
        /// </summary>
        /// <param name="projectManager">Project that produce this output</param>
        /// <param name="configuration">Configuration that produce this output</param>
        /// <param name="outputAssembly">MSBuild generated item corresponding to the output assembly (by default, these would be of type MainAssembly</param>
        public Output(ProjectNode projectManager, ProjectConfig configuration, ProjectElement outputAssembly)
        {
            if (projectManager == null)
                throw new ArgumentNullException("projectManager");
            if (configuration == null)
                throw new ArgumentNullException("configuration");
            if (outputAssembly == null)
                throw new ArgumentNullException("outputAssembly");

            project = projectManager;
            projectCfg = configuration;
            output = outputAssembly;
        }
示例#11
0
        /// <summary>
        /// Constructor to Wrap an existing MSBuild.BuildItem
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        /// <param name="project">Project that owns this item</param>
        /// <param name="existingItem">an MSBuild.BuildItem; can be null if virtualFolder is true</param>
        /// <param name="virtualFolder">Is this item virtual (such as reference folder)</param>
        internal ProjectElement(ProjectNode project, MSBuild.BuildItem existingItem, bool virtualFolder)
        {
            if (project == null)
                throw new ArgumentNullException("project");
            if (!virtualFolder && existingItem == null)
                throw new ArgumentNullException("existingItem");

            // Keep a reference to project and item
            this.itemProject = project;
            this.item = existingItem;
            this.isVirtual = virtualFolder;

            if (this.isVirtual)
                this.virtualProperties = new Dictionary<string, string>();
        }
示例#12
0
        /// <summary>
        /// Constructor to Wrap an existing MSBuild.BuildItem
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        /// <param name="project">Project that owns this item</param>
        /// <param name="existingItem">an MSBuild.BuildItem; can be null if virtualFolder is true</param>
        /// <param name="virtualFolder">Is this item virtual (such as reference folder)</param>
        internal ProjectElement(ProjectNode project, MSBuild.BuildItem existingItem, bool virtualFolder)
        {
            if (project == null)
                throw new ArgumentNullException("project", String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.AddToNullProjectError), existingItem.Include));
            if (!virtualFolder && existingItem == null)
                throw new ArgumentNullException("existingItem");

            // Keep a reference to project and item
            itemProject = project;
            item = existingItem;
            isVirtual = virtualFolder;

            if (isVirtual)
                virtualProperties = new Dictionary<string, string>();
        }
        /// <summary>
        /// Constructor for the ComReferenceNode. 
        /// </summary>
        public ComReferenceNode(ProjectNode root, ProjectElement element)
            : base(root, element)
        {
            this.typeName = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
            string typeGuidAsString = this.ItemNode.GetMetadata(ProjectFileConstants.Guid);
            if (typeGuidAsString != null)
            {
                this.typeGuid = new Guid(typeGuidAsString);
            }

            this.majorVersionNumber = this.ItemNode.GetMetadata(ProjectFileConstants.VersionMajor);
            this.minorVersionNumber = this.ItemNode.GetMetadata(ProjectFileConstants.VersionMinor);
            this.lcid = this.ItemNode.GetMetadata(ProjectFileConstants.Lcid);
            this.SetProjectItemsThatRelyOnReferencesToBeResolved(false);
            this.SetInstalledFilePath();
        }
示例#14
0
		/// <summary>
		/// Constructor for IVSOutputGroup2 implementation
		/// </summary>
		/// <param name="outputName">Name of the output group. See VS_OUTPUTGROUP_CNAME_Build in vsshell.idl for the list of standard values</param>
		/// <param name="msBuildTargetName">MSBuild target name</param>
		/// <param name="projectManager">Project that produce this output</param>
		/// <param name="configuration">Configuration that produce this output</param>
		public OutputGroup(string outputName, string msBuildTargetName, ProjectNode projectManager, ProjectConfig configuration)
		{
			if (outputName == null)
				throw new ArgumentNullException("outputName");
			if (msBuildTargetName == null)
				throw new ArgumentNullException("outputName");
			if (projectManager == null)
				throw new ArgumentNullException("projectManager");
			if (configuration == null)
				throw new ArgumentNullException("configuration");

			name = outputName;
			targetName = msBuildTargetName;
			project = projectManager;
			projectCfg = configuration;
		}
示例#15
0
 public BuildDependency(ProjectNode projectMgr, Guid projectReference)
 {
     this.referencedProjectGuid = projectReference;
     this.projectMgr = projectMgr;
 }
示例#16
0
 public ProjectDesignerDocumentManager(ProjectNode node)
     : base(node)
 {
 }
示例#17
0
        // no loggers
        internal static bool BuildInstance(ProjectNode projectNode, ProjectInstance instance, string target)
        {
            BuildSubmission submission = projectNode.DoMSBuildSubmission(BuildKind.SYNC, target, ref instance, null);

            return(submission.BuildResult.OverallResult == BuildResultCode.Success);
        }
示例#18
0
 /// <summary>
 /// constructor for the ReferenceNode
 /// </summary>
 protected ReferenceNode(ProjectNode root)
     : base(root)
 {
     this.ExcludeNodeFromScc = true;
 }
示例#19
0
 public ProjectNodeProperties(ProjectNode node)
     : base(node)
 {
 }
示例#20
0
        public virtual void SetObjects(uint count, object[] punk)
        {
            if (count > 0)
            {
                if (punk[0] is ProjectConfig)
                {
                    ArrayList configs = new ArrayList();

                    for (int i = 0; i < count; i++)
                    {
                        ProjectConfig config = (ProjectConfig)punk[i];

                        if (this.project == null)
                        {
                            this.project = config.ProjectMgr;
                        }

                        configs.Add(config);
                    }

                    this.projectConfigs = (ProjectConfig[])configs.ToArray(typeof(ProjectConfig));
                }
                else if (punk[0] is NodeProperties)
                {
                    if (this.project == null)
                    {
                        this.project = (punk[0] as NodeProperties).Node.ProjectMgr;
                    }

                    Dictionary<string, ProjectConfig> configsMap = new Dictionary<string, ProjectConfig>();

                    for (int i = 0; i < count; i++)
                    {
                        NodeProperties property = (NodeProperties)punk[i];
                        IVsCfgProvider provider;
                        ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider));
                        uint[] expected = new uint[1];
                        ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null));
                        if (expected[0] > 0)
                        {
                            ProjectConfig[] configs = new ProjectConfig[expected[0]];
                            uint[] actual = new uint[1];
                            provider.GetCfgs(expected[0], configs, actual, null);

                            foreach (ProjectConfig config in configs)
                            {
                                if (!configsMap.ContainsKey(config.ConfigName))
                                {
                                    configsMap.Add(config.ConfigName, config);
                                }
                            }
                        }
                    }

                    if (configsMap.Count > 0)
                    {
                        if (this.projectConfigs == null)
                        {
                            this.projectConfigs = new ProjectConfig[configsMap.Keys.Count];
                        }
                        configsMap.Values.CopyTo(this.projectConfigs, 0);
                    }
                }
            }
            else
            {
                this.project = null;
            }

            if (this.active && this.project != null)
            {
                UpdateObjects();
            }
        }
示例#21
0
 public RubyFileNode(ProjectNode root, ProjectElement e)
     : base(root, e)
 {
 }
 public ReferenceContainerNode(ProjectNode root) : base(root)
 {
     this.VirtualNodeName    = ReferencesNodeVirtualName;
     this.ExcludeNodeFromScc = true;
 }
示例#23
0
        public virtual void SetObjects(uint count, object[] punk)
        {
            if (count > 0)
            {
                if (punk[0] is ProjectConfig)
                {
                    ArrayList configs = new ArrayList();

                    for (int i = 0; i < count; i++)
                    {
                        ProjectConfig config = (ProjectConfig)punk[i];

                        if (this.project == null)
                        {
                            this.project = config.ProjectMgr;
                        }

                        configs.Add(config);
                    }

                    this.projectConfigs = (ProjectConfig[])configs.ToArray(typeof(ProjectConfig));
                }
                else if (punk[0] is NodeProperties)
                {
                    if (this.project == null)
                    {
                        this.project = (punk[0] as NodeProperties).Node.ProjectMgr;
                    }

                    Dictionary <string, ProjectConfig> configsMap = new Dictionary <string, ProjectConfig>();

                    for (int i = 0; i < count; i++)
                    {
                        NodeProperties property = (NodeProperties)punk[i];
                        IVsCfgProvider provider;
                        ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider));
                        uint[] expected = new uint[1];
                        ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null));
                        if (expected[0] > 0)
                        {
                            ProjectConfig[] configs = new ProjectConfig[expected[0]];
                            uint[]          actual  = new uint[1];
                            provider.GetCfgs(expected[0], configs, actual, null);

                            foreach (ProjectConfig config in configs)
                            {
                                if (!configsMap.ContainsKey(config.ConfigName))
                                {
                                    configsMap.Add(config.ConfigName, config);
                                }
                            }
                        }
                    }

                    if (configsMap.Count > 0)
                    {
                        if (this.projectConfigs == null)
                        {
                            this.projectConfigs = new ProjectConfig[configsMap.Keys.Count];
                        }
                        configsMap.Values.CopyTo(this.projectConfigs, 0);
                    }
                }
            }
            else
            {
                this.project = null;
            }

            if (this.active && this.project != null)
            {
                UpdateObjects();
            }
        }
示例#24
0
        /// <summary>
        /// The goal here is to reduce the risk of name conflict between 2 classes
        /// added in different directories. This code does NOT garanty uniqueness.
        /// To garanty uniqueness, you should change this function to work with
        /// the language service to verify that the namespace+class generated does
        /// not conflict.
        /// </summary>
        /// <param name="fileFullPath">Full path to the new file</param>
        /// <returns>Namespace to use for the new file</returns>
        public string GetFileNamespace(string fileFullPath, ProjectNode node)
        {
            // Get base namespace from the project
            string namespce = node.GetProjectProperty("RootNamespace");

            if (String.IsNullOrEmpty(namespce))
            {
                namespce = Path.GetFileNameWithoutExtension(fileFullPath);
            }
            ;

            // If the item is added to a subfolder, the name space should reflect this.
            // This is done so that class names from 2 files with the same name but different
            // directories don't conflict.
            string relativePath = Path.GetDirectoryName(fileFullPath);
            string projectPath  = Path.GetDirectoryName(node.GetMkDocument());

            // Our project system only support adding files that are sibling of the project file or that are in subdirectories.
            if (String.Compare(projectPath, 0, relativePath, 0, projectPath.Length, true, CultureInfo.CurrentCulture) == 0)
            {
                relativePath = relativePath.Substring(projectPath.Length);
            }
            else
            {
                Debug.Fail("Adding an item to the project that is NOT under the project folder.");
                // We are going to use the full file path for generating the namespace
            }

            // Get the list of parts
            int index = 0;

            string[] pathParts;
            pathParts = relativePath.Split(Path.DirectorySeparatorChar);

            // Use a string builder with default size being the expected size
            StringBuilder result = new StringBuilder(namespce, namespce.Length + relativePath.Length + 1);

            // For each path part
            while (index < pathParts.Length)
            {
                string part = pathParts[index];
                ++index;

                // This could happen if the path had leading/trailing slash, we want to ignore empty pieces
                if (String.IsNullOrEmpty(part))
                {
                    continue;
                }

                // If we reach here, we will be adding something, so add a namespace separator '.'
                result.Append('.');

                // Make sure it starts with a letter
                if (!char.IsLetter(part, 0))
                {
                    result.Append('N');
                }

                // Filter invalid namespace characters
                foreach (char c in part)
                {
                    if (char.IsLetterOrDigit(c))
                    {
                        result.Append(c);
                    }
                }
            }
            return(result.ToString());
        }
示例#25
0
 /// <summary>
 /// Constructor for the DependentFileNode
 /// </summary>
 /// <param name="root">Root of the hierarchy</param>
 /// <param name="e">Associated project element</param>
 public DependentFileNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     this.HasParentNodeNameRelation = false;
 }
示例#26
0
 /// <summary>
 /// constructor for the ReferenceNode
 /// </summary>
 protected ReferenceNode(ProjectNode root, ProjectElement e) : base(root, e)
 {
     this.ExcludeNodeFromScc = true;
 }
示例#27
0
 /// <summary>
 /// Constructor for the FolderNode
 /// </summary>
 /// <param name="root">Root node of the hierarchy</param>
 /// <param name="relativePath">relative path from root i.e.: "NewFolder1\\NewFolder2\\NewFolder3</param>
 /// <param name="element">Associated project element</param>
 public FolderNode(ProjectNode root, string relativePath, ProjectElement element)
     : base(root, element)
 {
     this.VirtualNodeName = relativePath.TrimEnd('\\');
 }
示例#28
0
 public NestedProjectNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     this.IsExpanded = true;
 }
示例#29
0
 /// <summary>
 /// Overloadde ctor.
 /// </summary>
 /// <param name="ProjectNode">The associated project</param>
 internal SingleFileGenerator(ProjectNode projectMgr)
 {
     this.projectMgr = projectMgr;
 }
示例#30
0
 /// <summary>
 /// Calling this method remove this item from the project file.
 /// Once the item is delete, you should not longer be using it.
 /// Note that the item should be removed from the hierarchy prior to this call.
 /// </summary>
 public void RemoveFromProjectFile()
 {
     if (!deleted && item != null)
     {
         deleted = true;
         itemProject.BuildProject.RemoveItem(item);
     }
     itemProject = null;
     item = null;
 }
示例#31
0
 public ReferenceContainerNode(ProjectNode root)
     : base(root)
 {
     this.VirtualNodeName = ReferencesNodeVirtualName;
     this.ExcludeNodeFromScc = true;
 }
示例#32
0
 /// <include file='doc\ProjectConfig.uex' path='docs/doc[@for="ProjectConfig.ProjectConfig"]/*' />
 public ProjectConfig(ProjectNode project, string configuration)
 {
     this.project    = project;
     this.configName = configuration;
 }
 public NestedProjectNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     this.IsExpanded = true;
 }
示例#34
0
 protected virtual OutputGroup CreateOutputGroup(ProjectNode project, KeyValuePair<string, string> group)
 {
     OutputGroup outputGroup = new OutputGroup(group.Key, group.Value, project, this);
     return outputGroup;
 }
示例#35
0
 /// <summary>
 /// constructor for the ReferenceNode
 /// </summary>
 protected ReferenceNode(ProjectNode root, ProjectElement e)
     : base(root,e)
 {
     this.ExcludeNodeFromScc = true;
 }
 internal MultiverseInterfacePythonFileNode(ProjectNode root, ProjectElement e)
     : base(root, e)
 {
 }
示例#37
0
 internal TrackDocumentsHelper(ProjectNode project)
 {
     this.projectMgr = project;
 }
示例#38
0
 /// <summary>
 /// Overloadde ctor.
 /// </summary>
 /// <param name="ProjectNode">The associated project</param>
 internal SingleFileGenerator(ProjectNode projectMgr)
 {
     this.projectMgr = projectMgr;
 }
示例#39
0
        public ProjectConfig(ProjectNode project, string configuration)
        {
            this.project = project;
            this.configName = configuration;

            // Because the project can be aggregated by a flavor, we need to make sure
            // we get the outer most implementation of that interface (hence: project --> IUnknown --> Interface)
            IntPtr projectUnknown = Marshal.GetIUnknownForObject(this.ProjectMgr);
            try
            {
                IVsProjectFlavorCfgProvider flavorCfgProvider = (IVsProjectFlavorCfgProvider)Marshal.GetTypedObjectForIUnknown(projectUnknown, typeof(IVsProjectFlavorCfgProvider));
                ErrorHandler.ThrowOnFailure(flavorCfgProvider.CreateProjectFlavorCfg(this, out flavoredCfg));
                if (flavoredCfg == null)
                    throw new COMException();
            }
            finally
            {
                if (projectUnknown != IntPtr.Zero)
                    Marshal.Release(projectUnknown);
            }
            // if the flavored object support XML fragment, initialize it
            IPersistXMLFragment persistXML = flavoredCfg as IPersistXMLFragment;
            if (null != persistXML)
            {
                this.project.LoadXmlFragment(persistXML, this.DisplayName);
            }
        }
示例#40
0
 public ConfigProvider(ProjectNode manager)
 {
     this.project = manager;
 }
        /// <summary>
        /// The goal here is to reduce the risk of name conflict between 2 classes
        /// added in different directories. This code does NOT garanty uniqueness.
        /// To garanty uniqueness, you should change this function to work with
        /// the language service to verify that the namespace+class generated does
        /// not conflict.
        /// </summary>
        /// <param name="fileFullPath">Full path to the new file</param>
        /// <returns>Namespace to use for the new file</returns>
        public string GetFileNamespace(string fileFullPath, ProjectNode node)
        {
            // Get base namespace from the project
            string namespce = node.GetProjectProperty("RootNamespace");
            if (String.IsNullOrEmpty(namespce))
                namespce = Path.GetFileNameWithoutExtension(fileFullPath); ;

            // If the item is added to a subfolder, the name space should reflect this.
            // This is done so that class names from 2 files with the same name but different
            // directories don't conflict.
            string relativePath = Path.GetDirectoryName(fileFullPath);
            string projectPath = Path.GetDirectoryName(node.GetMkDocument());
            // Our project system only support adding files that are sibling of the project file or that are in subdirectories.
            if (String.Compare(projectPath, 0, relativePath, 0, projectPath.Length, true, CultureInfo.CurrentCulture) == 0)
            {
                relativePath = relativePath.Substring(projectPath.Length);
            }
            else
            {
                Debug.Fail("Adding an item to the project that is NOT under the project folder.");
                // We are going to use the full file path for generating the namespace
            }

            // Get the list of parts
            int index = 0;
            string[] pathParts;
            pathParts = relativePath.Split(Path.DirectorySeparatorChar);

            // Use a string builder with default size being the expected size
            StringBuilder result = new StringBuilder(namespce, namespce.Length + relativePath.Length + 1);
            // For each path part
            while (index < pathParts.Length)
            {
                string part = pathParts[index];
                ++index;

                // This could happen if the path had leading/trailing slash, we want to ignore empty pieces
                if (String.IsNullOrEmpty(part))
                    continue;

                // If we reach here, we will be adding something, so add a namespace separator '.'
                result.Append('.');

                // Make sure it starts with a letter
                if (!char.IsLetter(part, 0))
                    result.Append('N');

                // Filter invalid namespace characters
                foreach (char c in part)
                {
                    if (char.IsLetterOrDigit(c))
                        result.Append(c);
                }
            }
            return result.ToString();
        }
示例#42
0
		public ProjectConfig(ProjectNode project, string configName, string platformName)
			: this(project, new ConfigCanonicalName(configName, platformName))
		{
		}
示例#43
0
		public DebuggableProjectConfig(ProjectNode project, ConfigCanonicalName conigName)
			: base(project, conigName)
		{
		}
示例#44
0
 /// <summary>
 /// constructor for the ReferenceNode
 /// </summary>
 protected ReferenceNode(ProjectNode root) : base(root)
 {
     this.ExcludeNodeFromScc = true;
 }
示例#45
0
 public BuildDependency(ProjectNode projectMgr, Guid projectReference)
 {
     this.referencedProjectGuid = projectReference;
     this.projectMgr            = projectMgr;
 }
示例#46
0
        protected virtual OutputGroup CreateOutputGroup(ProjectNode project, KeyValuePair <string, string> group)
        {
            OutputGroup outputGroup = new OutputGroup(group.Key, group.Value, project, this);

            return(outputGroup);
        }
 public BooProjectNodeProperties(ProjectNode node)
     : base(node)
 {
 }
示例#48
0
 /// <summary>
 /// Constructor for the FolderNode
 /// </summary>
 /// <param name="root">Root of the hierarchy</param>
 /// <param name="strDirectoryPath">Root of the hierarchy</param>
 /// <param name="e">Associated project element</param>
 public FolderNode(ProjectNode root, string strDirectoryPath, ProjectElement e)
     : base(root, e)
 {
     this.VirtualNodeName = strDirectoryPath.TrimEnd('\\');             //complete path from root project i.e.: "NewFolder1\\NewFolder2\\NewFolder3
 }