SolutionExplorer_OutOfProc.cs 5.9 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 50 51 52
        public void AddProjectReference(ProjectUtils.Project fromProjectName, ProjectUtils.ProjectReference toProjectName)
        {
           _inProc.AddProjectReference(fromProjectName.Name, toProjectName.Name);
            _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
        public void CleanUpOpenSolution()
            => _inProc.CleanUpOpenSolution();
M
Matt Warren 已提交
74

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

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

81 82
        public string GetFileContents(ProjectUtils.Project project, string fileName)
            => _inProc.GetFileContents(project.Name, fileName);
M
Matt Warren 已提交
83

J
Jonathon Marolf 已提交
84
        public void BuildSolution(bool waitForBuildToFinish)
85
            => _inProc.BuildSolution(waitForBuildToFinish);
M
Matt Warren 已提交
86

87 88
        public void OpenFileWithDesigner(ProjectUtils.Project project, string fileName)
            => _inProc.OpenFileWithDesigner(project.Name, fileName);
J
Jonathon Marolf 已提交
89

90 91
        public void OpenFile(ProjectUtils.Project project, string fileName)
            => _inProc.OpenFile(project.Name, fileName);
M
Matt Warren 已提交
92

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

96 97
        public void SaveFile(ProjectUtils.Project project, string fileName)
            => _inProc.SaveFile(project.Name, fileName);
J
Jonathon Marolf 已提交
98

99 100
        public void ReloadProject(ProjectUtils.Project project)
            => _inProc.ReloadProject(project.Name);
M
Matt Warren 已提交
101

102 103
        public void RestoreNuGetPackages()
            => _inProc.RestoreNuGetPackages();
M
Matt Warren 已提交
104

105 106
        public void SaveAll()
            => _inProc.SaveAll();
M
Matt Warren 已提交
107

108 109
        public void ShowOutputWindow()
            => _inProc.ShowOutputWindow();
M
Matt Warren 已提交
110

111 112
        public void UnloadProject(ProjectUtils.Project project)
            => _inProc.UnloadProject(project.Name);
M
Matt Warren 已提交
113

114 115
        public string[] GetProjectReferences(ProjectUtils.Project project)
            => _inProc.GetProjectReferences(project.Name);
116

117 118
        public string[] GetAssemblyReferences(ProjectUtils.Project project)
            => _inProc.GetAssemblyReferences(project.Name);
119

120 121 122 123 124 125 126 127 128
        public void SelectItem(string itemName)
            => _inProc.SelectItem(itemName);

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

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

129 130
        public void EditProjectFile(ProjectUtils.Project project)
            => _inProc.EditProjectFile(project.Name);
131 132 133

		public void AddStandaloneFile(string fileName)
            => _inProc.AddStandaloneFile(fileName);
134
    }
135
}