예제 #1
0
        internal static object GetCommonProject(this EnvDTE.Project project)
        {
            OAProject oaProj = project as OAProject;

            if (oaProj != null)
            {
                var common = oaProj.Project;
                if (common != null)
                {
                    return(common);
                }
            }
            return(null);
        }
예제 #2
0
        public static CommonProjectNode GetCommonProject(this EnvDTE.Project project)
        {
            OAProject oaProj = project as OAProject;

            if (oaProj != null)
            {
                var common = oaProj.Project as CommonProjectNode;
                if (common != null)
                {
                    return(common);
                }
            }
            return(null);
        }
예제 #3
0
        internal static OAProject GetActiveSolutionsProject()
        {
            IVsSolution ivsSolution = GetIVsSolution();

            EnvDTE80.DTE2 dte             = GetDTE2();
            var           activeSolutions = dte.Solution.DTE.ActiveSolutionProjects as object[];
            OAProject     oaProject       = null;

            if (activeSolutions != null && activeSolutions.Length > 0)
            {
                oaProject = activeSolutions[0] as OAProject;
                if (oaProject != null)
                {
                    Debug.WriteLine(oaProject.FullName);
                }
            }
            return(oaProject);
        }
예제 #4
0
        internal static RustProjectNode GetActiveRustProject()
        {
            IVsSolution ivsSolution = GetIVsSolution();

            EnvDTE80.DTE2   dte             = GetDTE2();
            var             activeSolutions = dte.Solution.DTE.ActiveSolutionProjects as object[];
            RustProjectNode rustProject     = null;

            if (activeSolutions != null && activeSolutions.Length > 0)
            {
                OAProject oaProject = activeSolutions[0] as OAProject;
                if (oaProject != null && oaProject.FileName.EndsWith(".rsproj"))
                {
                    rustProject = oaProject.Project as RustProjectNode;
                }
            }
            return(rustProject);
        }
예제 #5
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="project">Automation project.</param>
 /// <param name="node">Custom file node.</param>
 public OAMyCustomProjectFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OAWowFileItem"/> class.
 /// </summary>
 /// <param name="project">The project automation object.</param>
 /// <param name="node">The node.</param>
 public OAWowFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #7
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="project">Automation project.</param>
 /// <param name="node">Custom file node.</param>
 public OAIronRacketProjectFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #8
0
 public NemerleOAFolderItem(OAProject project, FolderNode node) : base(project, node)
 {
 }
예제 #9
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="project">Automation project.</param>
 /// <param name="node">Custom file node.</param>
 public OAXSharpFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="project">The associated project.</param>
 /// <param name="nodeWithItems">The node that defines the items.</param>
 internal OANavigableProjectItems(OAProject project, HierarchyNode nodeWithItems)
 {
     this.project       = project;
     this.nodeWithItems = nodeWithItems;
 }
예제 #11
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="project">Automation project.</param>
 /// <param name="node">Custom file node.</param>
 public SQAutomationProjectFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #12
0
 public NemerleOAReferenceItem(OAProject project, ReferenceNode node)
     : base(project, node)
 {
 }
예제 #13
0
 public OAComposeStarFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="project">Automation project.</param>
 /// <param name="node">Custom file node.</param>
 public OAUsagiProjectFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #15
0
 public OAClojureProjectFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #16
0
 internal OAReferenceFolderItem(OAProject project, ReferenceContainerNode node)
     : base(project, node)
 {
 }
예제 #17
0
 internal OAProjectItem(OAProject project, HierarchyNode node)
 {
     this.node    = node;
     this.project = project;
 }
예제 #18
0
 public NemerleOAReferenceFolderItem(OAProject project, ReferenceContainerNode node)
     : base(project, node)
 {
 }
예제 #19
0
 public NemerleOAFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #20
0
        public void TestAutomationOnProjectItems()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination = Path.Combine(TestContext.TestDir, TestContext.TestName);
                Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                OAProject automation = Utilities.FindExtObject(sp, Utilities.NestedProjectGuid, TestContext.TestName) as OAProject;
                Assert.IsNotNull(automation, "Failed to create a project using automation");

                string newModelFilePath = TestUtils.GetNewFileName(TestContext.TestDir, TestContext.TestName, "model");
                EnvDTE.ProjectItem pi   = automation.ProjectItems.AddFromFileCopy(Path.GetFullPath(newModelFilePath));
                Assert.IsNotNull(pi, "Failed to create a modeling project item through automation");
                Assert.IsTrue(pi.Name == Path.GetFileName(newModelFilePath), "ProjectItems AddFromFileCopy has not returned the item that was added");

                bool[] found = new bool[3];
                // Test enumerators on project items
                foreach (EnvDTE.ProjectItem item in automation.ProjectItems)
                {
                    if (item.Name == Path.GetFileName(newModelFilePath))
                    {
                        found[0] = true;
                    }
                    else if (item.Name == "Program.cs")
                    {
                        found[1] = true;
                    }
                    else if (item.Name == "AssemblyInfo.cs")
                    {
                        found[2] = true;
                    }
                }

                foreach (bool foundValue in found)
                {
                    Assert.IsTrue(foundValue, "The iterator on item collection has not been implemented correctly");
                }

                /*****Test the AddFolder method*****/
                //Add a simple folder to the project
                ProjectItem folder = automation.ProjectItems.AddFolder("directory", null);
                //Add a subfolder to the folder
                ProjectItem subfolder = folder.ProjectItems.AddFolder("subdirectory", string.Empty);
                //Add another subfolder to that folder
                subfolder.ProjectItems.AddFolder("subsubdirectory", EnvDTE.Constants.vsProjectItemKindPhysicalFolder);

                //Verify that we have the following structure:
                //Project
                //	-directory
                //		-subdirectory
                //			-subsubdirectory
                ProjectItem directory       = automation.ProjectItems.Item("directory") as ProjectItem;
                ProjectItem subdirectory    = directory.ProjectItems.Item("subdirectory") as ProjectItem;
                ProjectItem subsubdirectory = subdirectory.ProjectItems.Item("subsubdirectory") as ProjectItem;
                Assert.IsNotNull(directory);
                Assert.IsNotNull(subdirectory);
                Assert.IsNotNull(subsubdirectory);


                bool argumentExceptionThrown = false;
                try
                {
                    //We expect virtual folders to fail this way.
                    folder.ProjectItems.AddFolder("virtualfolder", EnvDTE.Constants.vsProjectItemKindVirtualFolder);
                }
                catch (ArgumentException) { argumentExceptionThrown = true; }
                Assert.IsTrue(argumentExceptionThrown);

                argumentExceptionThrown = false;
                try
                {
                    //Verify that you can't add a folder where a node with that name already exists
                    folder.ProjectItems.AddFolder("subdirectory", string.Empty);
                }
                catch (ArgumentException) { argumentExceptionThrown = true; }
                Assert.IsTrue(argumentExceptionThrown);
            });
        }
 public OAAndroidProjectFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
예제 #22
0
        public void TestAutomationOnProjectItem()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination = Path.Combine(TestContext.TestDir, TestContext.TestName);
                Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                OAProject automation = Utilities.FindExtObject(sp, Utilities.NestedProjectGuid, TestContext.TestName) as OAProject;
                Assert.IsNotNull(automation, "Failed to create a project using automation");

                ProjectNode project = automation.Project;

                // Get the AssemblyInfo.cs, try to open it and then ask using automation that it is opened.
                EnvDTE.ProjectItem item = automation.ProjectItems.Item("AssemblyInfo.cs");
                Assert.IsNotNull(item, "Could not retrieve AssemblyInfo.cs");

                EnvDTE.Window window = item.Open(VSConstants.LOGVIEWID_Primary.ToString());
                Assert.IsNotNull(window, "Could not open the AssemblyInfo.cs");
                window.Activate();

                bool isOpen = item.get_IsOpen(VSConstants.LOGVIEWID_Primary.ToString());
                Assert.IsTrue(isOpen, "The AssemblyInfo.cs file should have been opened");

                // Now save it
                item.Save("");

                Assert.IsTrue(item.Saved, "The renamed AssemblyInfo.cs has not been saved");

                // Get the Document
                EnvDTE.Document document = item.Document;
                Assert.IsNotNull(document, "Could not retrieve the document object");
                Assert.IsTrue(document.Name == "AssemblyInfo.cs", "The document for the file item is incorrect. It's name should be AssemblyInfo.cs");

                // Try the properties on a nested item
                EnvDTE.ProjectItem nestedProject     = automation.ProjectItems.Item("ANestedProject");
                EnvDTE.ProjectItem nestedProjectItem = nestedProject.ProjectItems.Item("Program.cs");
                EnvDTE.Properties nesteditemsProps   = nestedProjectItem.Properties;
                EnvDTE.Property nestedItemProperty   = nesteditemsProps.Item("BuildAction");
                Assert.IsNotNull(nestedItemProperty, "Could not retrieve the BuildAction property from the nested project item");
                nestedItemProperty.Value = BuildAction.Content;
                Assert.AreEqual((BuildAction)nestedItemProperty.Value, BuildAction.Content);

                // Now try the properties on the top project item
                EnvDTE.Properties props = item.Properties;
                Assert.IsNotNull(props, "Could not retrieve the BuildAction property from the nested project item");

                EnvDTE.Property itemProperty = props.Item("BuildAction");
                Assert.IsNotNull(itemProperty, "Could not retrieve the BuildAction property from the nested project item");
                Assert.IsFalse(itemProperty is OANullProperty, "Could not retrieve the BuildAction property from the nested project item");
                itemProperty.Value = BuildAction.Content;
                Assert.AreEqual(itemProperty.Value, BuildAction.Content);

                // Now save as
                Assert.IsTrue(item.SaveAs("AssemblyInfo1.cs"), "The file AssemblyInfo.cs could not be reanmed to AssemblyInfo1.cs");
                Assert.IsTrue(item.Name == "AssemblyInfo1.cs", "File item has been renamed to AssemblyInfo1.cs but the Name property has not");

                // Now try the Program.cs. That should not be opened
                EnvDTE.ProjectItem item1 = automation.ProjectItems.Item("Program.cs");

                Assert.IsNotNull(item1, "Could not retrieve AssemblyInfo.cs");

                isOpen = item1.get_IsOpen(VSConstants.LOGVIEWID_Primary.ToString());

                Assert.IsFalse(isOpen, "The Program.cs should not have been opened");

                // Now get the Reference folder as a project item and expand it.
                EnvDTE.ProjectItem references = automation.ProjectItems.Item("References");
                references.ExpandView();

                // Check that actually it was expanded.
                IVsUIHierarchyWindow uiHierarchy     = VsShellUtilities.GetUIHierarchyWindow(project.Site, HierarchyNode.SolutionExplorer);
                System.Reflection.MethodInfo mi      = typeof(ProjectNode).GetMethod("FindChild", BindingFlags.NonPublic | BindingFlags.Instance);
                ReferenceContainerNode containerNode = (ReferenceContainerNode)mi.Invoke(project, new object[] { "References" });

                __VSHIERARCHYITEMSTATE state;
                uint stateAsInt;
                uiHierarchy.GetItemState(project, (uint)containerNode.ID, (uint)__VSHIERARCHYITEMSTATE.HIS_Expanded, out stateAsInt);
                state = (__VSHIERARCHYITEMSTATE)stateAsInt;
                Assert.IsTrue(state == __VSHIERARCHYITEMSTATE.HIS_Expanded, "The References folder has not been expanded");
            });
        }
예제 #23
0
 public OAIronPythonFileItem(OAProject project, FileNode node)
     : base(project, node)
 {
 }
 public OASimpleFileItem(OAProject project, FileNode node) : base(project, node)
 {
 }
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="project">The project item</param>
        /// <param name="node">The documentation source node</param>
        public OADocumentationSourceItem(OAProject project, DocumentationSourceNode node) : base(project, node)
        {
        }
예제 #26
0
 internal OAReferenceItem(OAProject project, ReferenceNode node)
     : base(project, node)
 {
 }
예제 #27
0
        public void TestInterfaceMethodsOnProperty()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination = Path.Combine(TestContext.TestDir, TestContext.TestName);
                Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                OAProject automation = Utilities.FindExtObject(sp, Utilities.NestedProjectGuid, TestContext.TestName) as OAProject;
                Assert.IsNotNull(automation, "Failed to create a project using automation");

                ProjectNode projectNode = automation.Project;

                // Get Project Property object
                EnvDTE.Property property = automation.Properties.Item("RootNamespace");
                Assert.IsNotNull(property, "Could not retrieve valid RootNamespace property");
                Assert.IsFalse(property is OANullProperty, "Could not retrieve valid RootNamespace property");
                object retValue = property.Application;
                Assert.IsNull(retValue);

                Assert.IsTrue((string)property.Value == "Application", "Failed to retrieve the Value property.");
                property.Value = "Test1";
                Assert.AreEqual(property.Value, "Test1");


                // Get Collection object from property object
                EnvDTE.Properties properties = property.Collection;
                Assert.IsNotNull(properties, "Collection property failed to retrieve an object");

                // Get the DTE
                retValue = property.DTE;
                Assert.IsNotNull(retValue);

                // Get the Indexed value
                retValue = property.get_IndexedValue(1, 2, 3, 4);
                Assert.IsNull(retValue);

                property.let_Value(1);
                Assert.AreEqual(property.Value, "1");

                // Check the name.
                string name = property.Name;
                Assert.IsNotNull(name);
                Assert.IsTrue(name == "RootNamespace", "RootNamespace property was not set correctly");

                short numIndeces = property.NumIndices;
                //Currently it gives back 0
                //It must be Assertd when the method changes
                Assert.IsTrue(numIndeces == 0);

                // Assert the Object property
                retValue = property.Object;
                Assert.AreEqual(retValue, property.Value);
                property.Object = "test1";
                retValue        = property.Object;
                Assert.AreEqual(retValue, "test1");

                // Test the parent property
                EnvDTE.Properties parent = property.Parent;
                Assert.IsTrue(parent is OAProperties, "Parent property failed to return the parent of a property");

                //It does nothing currently. Cannot be Assertd.
                property.set_IndexedValue(1, 2, 3, 4, 5);

                // Try a non string value on the Value.
                ArrayList list = new ArrayList();
                property.Value = list;
                retValue       = property.Value;
                Assert.AreEqual(retValue, list.ToString());

                // Test the iterators for enumeration.
                // We are interested to see that we advance with the iteration.
                bool[] found = new bool[2];

                foreach (EnvDTE.Property aProperty in automation.Properties)
                {
                    if (aProperty.Name == "RootNamespace")
                    {
                        found[0] = true;
                    }
                    else if (aProperty.Name == "AssemblyName")
                    {
                        found[1] = true;
                    }
                }

                foreach (bool foundValue in found)
                {
                    Assert.IsTrue(foundValue, "The iterator on property collection has not been implemented correctly");
                }
            });
        }
예제 #28
0
 internal OAFolderItem(OAProject project, FolderNode node)
     : base(project, node)
 {
 }
예제 #29
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="project">The project node</param>
        /// <param name="node">The documentation sources container node</param>
        public OADocSourcesFolderItem(OAProject project, DocumentationSourcesContainerNode node) :
            base(project, node)
        {
        }
예제 #30
0
 internal OAProjectItems(OAProject project, HierarchyNode nodeWithItems)
     : base(project, nodeWithItems)
 {
 }