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); }
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); }
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); }
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); }
/// <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) { }
/// <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) { }
/// <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) { }
public NemerleOAFolderItem(OAProject project, FolderNode node) : base(project, node) { }
/// <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) { }
/// <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; }
/// <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) { }
public NemerleOAReferenceItem(OAProject project, ReferenceNode node) : base(project, node) { }
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) { }
public OAClojureProjectFileItem(OAProject project, FileNode node) : base(project, node) { }
internal OAReferenceFolderItem(OAProject project, ReferenceContainerNode node) : base(project, node) { }
internal OAProjectItem(OAProject project, HierarchyNode node) { this.node = node; this.project = project; }
public NemerleOAReferenceFolderItem(OAProject project, ReferenceContainerNode node) : base(project, node) { }
public NemerleOAFileItem(OAProject project, FileNode node) : base(project, node) { }
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) { }
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"); }); }
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) { }
internal OAReferenceItem(OAProject project, ReferenceNode node) : base(project, node) { }
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"); } }); }
internal OAFolderItem(OAProject project, FolderNode node) : base(project, node) { }
//===================================================================== /// <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) { }
internal OAProjectItems(OAProject project, HierarchyNode nodeWithItems) : base(project, nodeWithItems) { }