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(); }
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(); }