Пример #1
0
        private void CleanupHostSide()
        {
            lock (m_hostSideLock)
            {
                Debug.Assert(HostSide != null);

                if (HostSide != null)
                {
                    try
                    {
                        ((ITestAdapter)HostSide).Cleanup();
                    }
                    catch (Exception ex)    // We don't know what this can throw in advance.
                    {
                        SendResult(string.Format(CultureInfo.InvariantCulture, Resources.FailedToCallTACleanup, ex), TestOutcome.Warning);
                    }
                }

                try
                {
                    Debug.Assert(m_vsIde != null);
                    m_vsIde.Dispose();
                }
                catch (Exception ex)
                {
                    SendResult(string.Format(CultureInfo.InvariantCulture, Resources.ErrorShuttingDownVS, ex), TestOutcome.Warning);
                }

                m_vsIde    = null;
                m_hostSide = null;  // Note: host side lifetime is controlled by the addin.
            }
        }
Пример #2
0
        private void CreateHostSide()
        {
            // Note: we already have try-catch-Debug.Fail in Initialize that calls this method.
            // Note: registryHive can be null when using HostType attribute. In this case we'll use default hive.
            Debug.Assert(!string.IsNullOrEmpty(m_workingDir));
            // Note: registryHive can be null when using the attribute. That's OK, VsIde will figure out.
            Debug.Assert(!string.IsNullOrEmpty(m_workingDir));
            Debug.Assert(m_hostSide == null, "HA.CreateHostSide: m_hostSide should be null (ignorable).");
            Debug.Assert(m_vsIde == null, "HA.CreateHostSide: m_vsIde should be null (ignorable).");

            // Start devenv.
            m_vsIde = new VisualStudioIde(new VsIdeStartupInfo(m_vsRegistryHive, m_workingDir));
            m_vsIde.ErrorHandler += HostProcessErrorHandler;

            Stopwatch timer = Stopwatch.StartNew();

            do
            {
                try
                {
                    m_vsIde.Dte.MainWindow.Visible = true;    // This could be in TestRunConfig options for this host type.
                    break;
                }
                catch (Exception)
                {
                }
                System.Threading.Thread.Sleep(RegistrySettings.BaseSleepDuration);
            } while (timer.Elapsed < s_ideStartupTimeout);

            m_hostSide = GetHostSideFromAddin();
        }