SolutionExplorer_OutOfProc.cs 8.3 KB
Newer Older
1 2
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

3
using System.Xml.Linq;
4
using Microsoft.CodeAnalysis.Shared.TestHooks;
5
using Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess;
6
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;
7

8
namespace Microsoft.VisualStudio.IntegrationTest.Utilities.OutOfProcess
9
{
10
    public partial class SolutionExplorer_OutOfProc : OutOfProcComponent
11
    {
12 13
        public Verifier Verify { get; }

14
        private readonly SolutionExplorer_InProc _inProc;
15
        private readonly VisualStudioInstance _instance;
16

17 18 19
        public SolutionExplorer_OutOfProc(VisualStudioInstance visualStudioInstance)
            : base(visualStudioInstance)
        {
20
            _instance = visualStudioInstance;
21
            _inProc = CreateInProcComponent<SolutionExplorer_InProc>(visualStudioInstance);
22
            Verify = new Verifier(this);
23 24
        }

25 26
        public void CloseSolution(bool saveFirst = false)
            => _inProc.CloseSolution(saveFirst);
27

28 29 30 31 32
        /// <summary>
        /// The full file path to the solution file.
        /// </summary>
        public string SolutionFileFullPath => _inProc.SolutionFileFullPath;

33 34 35
        /// <summary>
        /// Creates and loads a new solution in the host process, optionally saving the existing solution if one exists.
        /// </summary>
36 37
        public void CreateSolution(string solutionName, bool saveExistingSolutionIfExists = false)
            => _inProc.CreateSolution(solutionName, saveExistingSolutionIfExists);
38

39 40 41
        public void CreateSolution(string solutionName, XElement solutionElement)
            => _inProc.CreateSolution(solutionName, solutionElement.ToString());

42 43
        public void OpenSolution(string path, bool saveExistingSolutionIfExists = false)
            => _inProc.OpenSolution(path, saveExistingSolutionIfExists);
44

45 46
        public void AddProject(ProjectUtils.Project projectName, string projectTemplate, string languageName)
            => _inProc.AddProject(projectName.Name, projectTemplate, languageName);
47

48 49
        public void AddProjectReference(ProjectUtils.Project fromProjectName, ProjectUtils.ProjectReference toProjectName)
        {
50
            _inProc.AddProjectReference(fromProjectName.Name, toProjectName.Name);
51 52
            _instance.Workspace.WaitForAsyncOperations(FeatureAttribute.Workspace);
        }
53

54 55 56 57 58
        public void RemoveProjectReference(ProjectUtils.Project projectName, ProjectUtils.ProjectReference projectReferenceName)
        {
            _inProc.RemoveProjectReference(projectName.Name, projectReferenceName.Name);
            _instance.Workspace.WaitForAsyncOperations(FeatureAttribute.Workspace);
        }
59

60 61 62 63 64
        public void AddMetadataReference(ProjectUtils.AssemblyReference fullyQualifiedAssemblyName, ProjectUtils.Project projectName)
        {
            _inProc.AddMetadataReference(fullyQualifiedAssemblyName.Name, projectName.Name);
            _instance.Workspace.WaitForAsyncOperations(FeatureAttribute.Workspace);
        }
65

66 67 68 69 70
        public void RemoveMetadataReference(ProjectUtils.AssemblyReference assemblyName, ProjectUtils.Project projectName)
        {
            _inProc.RemoveMetadataReference(assemblyName.Name, projectName.Name);
            _instance.Workspace.WaitForAsyncOperations(FeatureAttribute.Workspace);
        }
71

72 73 74 75 76 77 78 79 80 81 82 83 84 85
        /// <summary>
        /// Add a PackageReference to the specified project. Generally this should be followed up by
        /// a call to <see cref="RestoreNuGetPackages"/>.
        /// </summary>
        public void AddPackageReference(ProjectUtils.Project project, ProjectUtils.PackageReference package)
            => _inProc.AddPackageReference(project.Name, package.Name, package.Version);

        /// <summary>
        /// Remove a PackageReference from the specified project. Generally this should be followed up by
        /// a call to <see cref="RestoreNuGetPackages"/>.
        /// </summary>
        public void RemovePackageReference(ProjectUtils.Project project, ProjectUtils.PackageReference package)
            => _inProc.RemovePackageReference(project.Name, package.Name);

86 87
        public void CleanUpOpenSolution()
            => _inProc.CleanUpOpenSolution();
M
Matt Warren 已提交
88

89 90
        public void AddFile(ProjectUtils.Project project, string fileName, string contents = null, bool open = false)
            => _inProc.AddFile(project.Name, fileName, contents, open);
M
Matt Warren 已提交
91

92 93
        public void SetFileContents(ProjectUtils.Project project, string fileName, string contents)
            => _inProc.SetFileContents(project.Name, fileName, contents);
M
Matt Warren 已提交
94

95 96
        public string GetFileContents(ProjectUtils.Project project, string fileName)
            => _inProc.GetFileContents(project.Name, fileName);
M
Matt Warren 已提交
97

J
Jonathon Marolf 已提交
98
        public void BuildSolution(bool waitForBuildToFinish)
99
            => _inProc.BuildSolution(waitForBuildToFinish);
M
Matt Warren 已提交
100

101 102
        public void OpenFileWithDesigner(ProjectUtils.Project project, string fileName)
            => _inProc.OpenFileWithDesigner(project.Name, fileName);
J
Jonathon Marolf 已提交
103

104 105
        public void OpenFile(ProjectUtils.Project project, string fileName)
            => _inProc.OpenFile(project.Name, fileName);
M
Matt Warren 已提交
106

107 108 109
        public void UpdateFile(string projectName, string fileName, string contents, bool open = false)
            => _inProc.UpdateFile(projectName, fileName, contents, open);

110 111 112
        public void RenameFile(ProjectUtils.Project project, string oldFileName, string newFileName)
            => _inProc.RenameFile(project.Name, oldFileName, newFileName);

113 114
        public void CloseFile(ProjectUtils.Project project, string fileName, bool saveFile)
            => _inProc.CloseFile(project.Name, fileName, saveFile);
J
Jonathon Marolf 已提交
115

116 117
        public void SaveFile(ProjectUtils.Project project, string fileName)
            => _inProc.SaveFile(project.Name, fileName);
J
Jonathon Marolf 已提交
118

119 120
        public void ReloadProject(ProjectUtils.Project project)
            => _inProc.ReloadProject(project.RelativePath);
M
Matt Warren 已提交
121

122 123
        public void RestoreNuGetPackages()
            => _inProc.RestoreNuGetPackages();
M
Matt Warren 已提交
124

125 126
        public void SaveAll()
            => _inProc.SaveAll();
M
Matt Warren 已提交
127

128 129
        public void ShowOutputWindow()
            => _inProc.ShowOutputWindow();
M
Matt Warren 已提交
130

131 132
        public void UnloadProject(ProjectUtils.Project project)
            => _inProc.UnloadProject(project.Name);
M
Matt Warren 已提交
133

134 135
        public string[] GetProjectReferences(ProjectUtils.Project project)
            => _inProc.GetProjectReferences(project.Name);
136

137 138
        public string[] GetAssemblyReferences(ProjectUtils.Project project)
            => _inProc.GetAssemblyReferences(project.Name);
139

140 141 142 143 144 145
        /// <summary>
        /// Selects an item named by the <paramref name="itemName"/> parameter.
        /// Note that this selects the first item of the given name found. In situations where
        /// there may be more than one item of a given name, use <see cref="SelectItemAtPath(string[])"/>
        /// instead.
        /// </summary>
146 147 148
        public void SelectItem(string itemName)
            => _inProc.SelectItem(itemName);

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
        /// <summary>
        /// Selects the specific item at the given "path".
        /// </summary>
        public void SelectItemAtPath(params string[] path)
            => _inProc.SelectItemAtPath(path);

        /// <summary>
        /// Returns the names of the immediate children of the given item.
        /// Note that this uses the first item of the given name found. In situations where there
        /// may be more than one item of a given name, use <see cref="GetChildrenOfItemAtPath(string[])"/>
        /// instead.
        /// </summary>
        public string[] GetChildrenOfItem(string itemName)
            => _inProc.GetChildrenOfItem(itemName);

        /// <summary>
        /// Returns the names of the immediate children of the item at the given "path".
        /// </summary>
        public string[] GetChildrenOfItemAtPath(params string[] path)
            => _inProc.GetChildrenOfItemAtPath(path);

170 171 172 173 174 175
        public void ClearBuildOutputWindowPane()
            => _inProc.ClearBuildOutputWindowPane();

        public void WaitForBuildToFinish()
            => _inProc.WaitForBuildToFinish();

176 177
        public void EditProjectFile(ProjectUtils.Project project)
            => _inProc.EditProjectFile(project.Name);
178

179
        public void AddStandaloneFile(string fileName)
180
            => _inProc.AddStandaloneFile(fileName);
181
    }
S
Sam Harwell 已提交
182
}