コード例 #1
0
        public VisualStudioInstance(Process hostProcess, EnvDTE.DTE dte)
        {
            _hostProcess = hostProcess;
            _dte         = dte;

            StartRemoteIntegrationService(dte);

            _integrationServiceChannel = new IpcClientChannel($"IPC channel client for {_hostProcess.Id}", sinkProvider: null);
            ChannelServices.RegisterChannel(_integrationServiceChannel, ensureSecurity: true);

            // Connect to a 'well defined, shouldn't conflict' IPC channel
            _integrationService = IntegrationService.GetInstanceFromHostProcess(hostProcess);

            // Create marshal-by-ref object that runs in host-process.
            _inProc = ExecuteInHostProcess <VisualStudio_InProc>(
                type: typeof(VisualStudio_InProc),
                methodName: nameof(VisualStudio_InProc.Create));

            // There is a lot of VS initialization code that goes on, so we want to wait for that to 'settle' before
            // we start executing any actual code.
            _inProc.WaitForSystemIdle();

            this.CSharpInteractiveWindow = new CSharpInteractiveWindow_OutOfProc(this);
            this.Editor                = new Editor_OutOfProc(this);
            this.SolutionExplorer      = new SolutionExplorer_OutOfProc(this);
            this.VisualStudioWorkspace = new VisualStudioWorkspace_OutOfProc(this);

            this.SendKeys = new SendKeys(this);

            // Ensure we are in a known 'good' state by cleaning up anything changed by the previous instance
            CleanUp();
        }
コード例 #2
0
 protected AbstractIntegrationTest(
     VisualStudioInstanceFactory instanceFactory,
     Func <VisualStudioInstanceContext, TextViewWindow_OutOfProc> textViewWindowBuilder)
 {
     VisualStudio   = instanceFactory.GetNewOrUsedInstance(SharedIntegrationHostFixture.RequiredPackageIds);
     TextViewWindow = textViewWindowBuilder(VisualStudio);
     VisualStudioWorkspaceOutOfProc = VisualStudio.Instance.VisualStudioWorkspace;
 }
コード例 #3
0
        protected AbstractEditorTest(VisualStudioInstanceFactory instanceFactory, string solutionName)
            : base(instanceFactory)
        {
            VisualStudio.Instance.SolutionExplorer.CreateSolution(solutionName);
            VisualStudio.Instance.SolutionExplorer.AddProject(ProjectName, WellKnownProjectTemplates.ClassLibrary, LanguageName);

            VisualStudioWorkspaceOutOfProc = VisualStudio.Instance.VisualStudioWorkspace;
            VisualStudioWorkspaceOutOfProc.SetUseSuggestionMode(false);

            Editor = VisualStudio.Instance.Editor;

            ClearEditor();
        }
コード例 #4
0
        public VisualStudioInstance(Process hostProcess, DTE dte, ImmutableHashSet <string> supportedPackageIds, string installationPath)
        {
            HostProcess         = hostProcess;
            Dte                 = dte;
            SupportedPackageIds = supportedPackageIds;
            InstallationPath    = installationPath;

            StartRemoteIntegrationService(dte);

            _integrationServiceChannel = new IpcClientChannel(GetIpcClientChannelName(HostProcess), sinkProvider: null);
            ChannelServices.RegisterChannel(_integrationServiceChannel, ensureSecurity: true);

            // Connect to a 'well defined, shouldn't conflict' IPC channel
            _integrationService = IntegrationService.GetInstanceFromHostProcess(hostProcess);

            // Create marshal-by-ref object that runs in host-process.
            _inProc = ExecuteInHostProcess <VisualStudio_InProc>(
                type: typeof(VisualStudio_InProc),
                methodName: nameof(VisualStudio_InProc.Create)
                );

            // There is a lot of VS initialization code that goes on, so we want to wait for that to 'settle' before
            // we start executing any actual code.
            _inProc.WaitForSystemIdle();

            ChangeSignatureDialog = new ChangeSignatureDialog_OutOfProc(this);
            InteractiveWindow     = new CSharpInteractiveWindow_OutOfProc(this);
            ObjectBrowserWindow   = new ObjectBrowserWindow_OutOfProc(this);
            Debugger               = new Debugger_OutOfProc(this);
            Dialog                 = new Dialog_OutOfProc(this);
            Editor                 = new Editor_OutOfProc(this);
            EncapsulateField       = new EncapsulateField_OutOfProc(this);
            ErrorList              = new ErrorList_OutOfProc(this);
            ExtractInterfaceDialog = new ExtractInterfaceDialog_OutOfProc(this);
            FindReferencesWindow   = new FindReferencesWindow_OutOfProc(this);
            GenerateTypeDialog     = new GenerateTypeDialog_OutOfProc(this);
            InlineRenameDialog     = new InlineRenameDialog_OutOfProc(this);
            ImmediateWindow        = new ImmediateWindow_OutOfProc(this);
            LocalsWindow           = new LocalsWindow_OutOfProc(this);
            PickMembersDialog      = new PickMembersDialog_OutOfProc(this);
            PreviewChangesDialog   = new PreviewChangesDialog_OutOfProc(this);
            Shell            = new Shell_OutOfProc(this);
            SolutionExplorer = new SolutionExplorer_OutOfProc(this);
            Workspace        = new VisualStudioWorkspace_OutOfProc(this);
            StartPage        = new StartPage_OutOfProc(this);

            SendKeys = new SendKeys(this);

            // Ensure we are in a known 'good' state by cleaning up anything changed by the previous instance
            CleanUp();
        }
コード例 #5
0
        protected AbstractEditorTests(VisualStudioInstanceFactory instanceFactory, string solutionName)
        {
            _visualStudio = instanceFactory.GetNewOrUsedInstance();

            _visualStudio.Instance.SolutionExplorer.CreateSolution(solutionName);
            _visualStudio.Instance.SolutionExplorer.AddProject("TestProj", WellKnownProjectTemplates.ClassLibrary, LanguageName);

            _visualStudioWorkspaceOutOfProc = _visualStudio.Instance.VisualStudioWorkspace;
            _visualStudioWorkspaceOutOfProc.SetUseSuggestionMode(false);

            _editor = _visualStudio.Instance.Editor;

            ClearEditor();
        }
コード例 #6
0
        protected AbstractEditorTest(
            VisualStudioInstanceFactory instanceFactory,
            string solutionName,
            string projectTemplate)
            : base(instanceFactory)
        {
            VisualStudio.Instance.SolutionExplorer.CreateSolution(solutionName);
            VisualStudio.Instance.SolutionExplorer.AddProject(ProjectName, projectTemplate, LanguageName);

            VisualStudioWorkspaceOutOfProc = VisualStudio.Instance.VisualStudioWorkspace;
            Editor = VisualStudio.Instance.Editor;

            // Winforms and XAML do not open text files on creation
            // so these editor tasks will not work if that is the project template being used.
            if (projectTemplate != WellKnownProjectTemplates.WinFormsApplication &&
                projectTemplate != WellKnownProjectTemplates.WpfApplication)
            {
                VisualStudioWorkspaceOutOfProc.SetUseSuggestionMode(false);
                ClearEditor();
            }
        }
コード例 #7
0
        public VisualStudioInstance(Process hostProcess, DTE dte, ImmutableHashSet <string> supportedPackageIds, string installationPath)
        {
            HostProcess         = hostProcess;
            Dte                 = dte;
            SupportedPackageIds = supportedPackageIds;
            InstallationPath    = installationPath;

            if (System.Diagnostics.Debugger.IsAttached)
            {
                // If a Visual Studio debugger is attached to the test process, attach it to the instance running
                // integration tests as well.
                var debuggerHostDte = GetDebuggerHostDte();
                var targetProcessId = Process.GetCurrentProcess().Id;
                var localProcess    = debuggerHostDte?.Debugger.LocalProcesses.OfType <EnvDTE80.Process2>().FirstOrDefault(p => p.ProcessID == hostProcess.Id);
                if (localProcess != null)
                {
                    localProcess.Attach2("Managed");
                }
            }

            StartRemoteIntegrationService(dte);

            _integrationServiceChannel = new IpcClientChannel(GetIpcClientChannelName(HostProcess), sinkProvider: null);
            ChannelServices.RegisterChannel(_integrationServiceChannel, ensureSecurity: true);

            // Connect to a 'well defined, shouldn't conflict' IPC channel
            _integrationService = IntegrationService.GetInstanceFromHostProcess(hostProcess);

            // Create marshal-by-ref object that runs in host-process.
            _inProc = ExecuteInHostProcess <VisualStudio_InProc>(
                type: typeof(VisualStudio_InProc),
                methodName: nameof(VisualStudio_InProc.Create)
                );

            // There is a lot of VS initialization code that goes on, so we want to wait for that to 'settle' before
            // we start executing any actual code.
            _inProc.WaitForSystemIdle();

            AddParameterDialog    = new AddParameterDialog_OutOfProc(this);
            ChangeSignatureDialog = new ChangeSignatureDialog_OutOfProc(this);
            InteractiveWindow     = new CSharpInteractiveWindow_OutOfProc(this);
            ObjectBrowserWindow   = new ObjectBrowserWindow_OutOfProc(this);
            Debugger               = new Debugger_OutOfProc(this);
            Dialog                 = new Dialog_OutOfProc(this);
            Editor                 = new Editor_OutOfProc(this);
            EncapsulateField       = new EncapsulateField_OutOfProc(this);
            ErrorList              = new ErrorList_OutOfProc(this);
            ExtractInterfaceDialog = new ExtractInterfaceDialog_OutOfProc(this);
            FindReferencesWindow   = new FindReferencesWindow_OutOfProc(this);
            GenerateTypeDialog     = new GenerateTypeDialog_OutOfProc(this);
            InlineRenameDialog     = new InlineRenameDialog_OutOfProc(this);
            ImmediateWindow        = new ImmediateWindow_OutOfProc(this);
            LocalsWindow           = new LocalsWindow_OutOfProc(this);
            MoveToNamespaceDialog  = new MoveToNamespaceDialog_OutOfProc(this);
            PickMembersDialog      = new PickMembersDialog_OutOfProc(this);
            PreviewChangesDialog   = new PreviewChangesDialog_OutOfProc(this);
            Shell            = new Shell_OutOfProc(this);
            SolutionExplorer = new SolutionExplorer_OutOfProc(this);
            Workspace        = new VisualStudioWorkspace_OutOfProc(this);
            StartPage        = new StartPage_OutOfProc(this);

            SendKeys = new SendKeys(this);

            // Ensure we are in a known 'good' state by cleaning up anything changed by the previous instance
            CleanUp();
        }
コード例 #8
0
 protected AbstractEditorTest(VisualStudioInstanceFactory instanceFactory)
     : base(instanceFactory)
 {
     VisualStudioWorkspaceOutOfProc = VisualStudio.Instance.VisualStudioWorkspace;
     Editor = VisualStudio.Instance.Editor;
 }