[SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")] // TODO: should we care about rightAlign? -- no unless we ship this HA. void IRunConfigurationCustomHostEditor.SetData(IHostSpecificRunConfigurationData data) { string currentVersion = VSRegistry.GetDefaultVersion(); // Throws if VS is not installed. VsIdeHostRunConfigData vsIdeHostData = data as VsIdeHostRunConfigData; if (vsIdeHostData == null) { vsIdeHostData = new VsIdeHostRunConfigData(currentVersion); // TODO: SetDirty() that set run config to dirty is disabled in parent during Initialize/SetData, so this makes no effect. SetDirty(); } else if (!m_hiveCombo.Items.Contains(vsIdeHostData.RegistryHive)) { // If .testrunconfig file has VS version that we do not have in combobox, // show message box and use default version. MessageBox.Show( this, Resources.WrongVSVersionPassedToRunConfigControl(vsIdeHostData.RegistryHive, currentVersion), Resources.MicrosoftVisualStudio); vsIdeHostData.RegistryHive = currentVersion; // TODO: SetDirty() that set run config to dirty is disabled in parent during Initialize/SetData, so this makes no effect. SetDirty(); } // Set the data. m_data = vsIdeHostData; int selectedIndex = m_hiveCombo.Items.IndexOf(vsIdeHostData.RegistryHive); if (selectedIndex < 0) { selectedIndex = m_hiveCombo.Items.IndexOf(currentVersion); Debug.Assert(selectedIndex >= 0); } if (selectedIndex >= 0) { m_hiveCombo.SelectedIndex = selectedIndex; } m_additionalCommandLineArgumentsEdit.Text = vsIdeHostData.AdditionalCommandLineArguments; m_additionalTestDataEdit.Text = vsIdeHostData.AdditionalTestData; }
// Create a DevEnv process private void StartNewInstance(VsIdeStartupInfo info) { Debug.Assert(info != null); Debug.Assert(m_process == null, "VisualStudioIde.StartNewInstance: m_process should be null!"); if (string.IsNullOrEmpty(info.RegistryHive)) { info.RegistryHive = VSRegistry.GetDefaultVersion(); if (string.IsNullOrEmpty(info.RegistryHive)) { // Please no Debug.Assert. This is a valid case. throw new VsIdeTestHostException(Resources.CannotFindVSInstallation(info.RegistryHive)); } } Process process = new Process(); process.StartInfo.UseShellExecute = false; if (info.WorkingDirectory != null) { process.StartInfo.WorkingDirectory = info.WorkingDirectory; } process.StartInfo.FileName = VSRegistry.GetVSLocation(info.RegistryHive); Debug.Assert(!string.IsNullOrEmpty(process.StartInfo.FileName)); // Note that this needs to be partial (not $-terminated) as we partially match/replace. Regex versionRegex = new Regex(@"^[0-9]+\.[0-9]+"); string hiveVersion = versionRegex.Match(info.RegistryHive).Value; string hiveSuffix = versionRegex.Replace(info.RegistryHive, string.Empty); if (!string.IsNullOrEmpty(hiveSuffix)) { process.StartInfo.Arguments = "/RootSuffix " + hiveSuffix; } if (!string.IsNullOrEmpty(info.AdditionalCommandLineArguments)) { if (!string.IsNullOrEmpty(process.StartInfo.Arguments)) { process.StartInfo.Arguments += " "; } process.StartInfo.Arguments += info.AdditionalCommandLineArguments; } process.Exited += new EventHandler(ProcessExited); process.EnableRaisingEvents = true; if (!process.Start()) { throw new VsIdeTestHostException(Resources.FailedToStartVSProcess); } m_process = process; string progId = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", VisualStudioIde.BaseProgId, hiveVersion); m_dte = GetDteFromRot(progId, m_process.Id); Debug.Assert(m_dte != null); }