public CSharpAutomaticBraceCompletion(VisualStudioInstanceFactory instanceFactory)
        {
            _visualStudio = instanceFactory.GetNewOrUsedInstance();

            _solution = _visualStudio.Instance.SolutionExplorer.CreateSolution(nameof(CSharpAutomaticBraceCompletion));
            _project = _solution.AddProject("TestProj", ProjectTemplate.ClassLibrary, ProjectLanguage.CSharp);

            _workspace = _visualStudio.Instance.Workspace;
            _workspace.UseSuggestionMode = false;

            _editorWindow = _visualStudio.Instance.EditorWindow;
        }
Beispiel #2
0
        public Solution OpenSolution(string path, bool saveExistingSolutionIfExists = false)
        {
            var dteSolution = IntegrationHelper.RetryRpcCall(() => _visualStudio.Dte.Solution);

            if (IntegrationHelper.RetryRpcCall(() => dteSolution.IsOpen))
            {
                CloseSolution(saveExistingSolutionIfExists);
            }

            IntegrationHelper.RetryRpcCall(() => dteSolution.Open(path));
            _solution = new Solution((Solution2)(dteSolution), path);

            return _solution;
        }
Beispiel #3
0
        internal Project(DteProject dteProject, Solution solution, ProjectLanguage language)
        {
            if (dteProject == null)
            {
                throw new ArgumentNullException(nameof(dteProject));
            }

            if (solution == null)
            {
                throw new ArgumentNullException(nameof(solution));
            }

            _dteProject = dteProject;
            _solution = solution;
            _language = language;
        }
        /// <summary>Creates and loads a new solution in the host process, optionally saving the existing solution if one exists.</summary>
        public Solution CreateSolution(string solutionName, bool saveExistingSolutionIfExists = false)
        {
            var dteSolution = IntegrationHelper.RetryRpcCall(() => _visualStudio.Dte.Solution);

            if (IntegrationHelper.RetryRpcCall(() => dteSolution.IsOpen))
            {
                CloseSolution(saveExistingSolutionIfExists);
            }

            var solutionPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            IntegrationHelper.DeleteDirectoryRecursively(solutionPath);

            IntegrationHelper.RetryRpcCall(() => dteSolution.Create(solutionPath, solutionName));
            _solution = new Solution((Solution2)(dteSolution), Path.Combine(solutionPath, $"{solutionName}.sln"));

            return _solution;
        }