tools/VsIdeHostAdapter/TargetAddIn/AgentSide/VsIdeHostAdapter.cs
/// <summary>
/// ITestAdapter method: called to initialize run context for this adapter.
/// </summary>
/// <param name="runContext">The run context to be used for this run</param>
ITestAdapter method: called to initialize run context for this adapter.
ITestAdapter method : called to initialize run context for this adapter .
[SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#")]  
        void ITestAdapter.Initialize(IRunContext runContext)
        {
            Debug.Assert(runContext != null);
            m_runContext = runContext;
            m_runConfig = m_runContext.RunConfig.TestRun.RunConfiguration;
            m_workingDir = m_runContext.RunContextVariables.GetStringValue("TestDeploymentDir");
            Debug.Assert(m_runConfig != null);
            Debug.Assert(!string.IsNullOrEmpty(m_workingDir));
            SetupChannels();
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                try
                {
                    m_comMessageFilter = new RetryMessageFilter();
                }
                catch (COMException ex)
                {
                    string message = "Failed to create COM filter (ignorable): " + ex.ToString();
                    Debug.Fail(message);
                    SendResult(ex.Message, TestOutcome.Warning, false);
                }
            }
            else
            {
                TraceMessage("COM message filter is disabled because it can be registered only in STA apartment, and current apartment is " +
                    Thread.CurrentThread.GetApartmentState().ToString());
            }
            InitHostSession();
        }
[ SuppressMessage ( " " , " " , MessageId = " " ) ] void ITestAdapter . Initialize ( IRunContext runContext ) { Debug . Assert ( runContext != null ) ; m_runContext = runContext ; m_runConfig = m_runContext . RunConfig . TestRun . RunConfiguration ; m_workingDir = m_runContext . RunContextVariables . GetStringValue ( " " ) ; Debug . Assert ( m_runConfig != null ) ; Debug . Assert ( ! string . IsNullOrEmpty ( m_workingDir ) ) ; SetupChannels ( ) ; if ( Thread . CurrentThread . GetApartmentState ( ) == ApartmentState . STA ) { try { m_comMessageFilter = new RetryMessageFilter ( ) ; } catch ( COMException ex ) { string message = " " + ex . ToString ( ) ; Debug . Fail ( message ) ; SendResult ( ex . Message , TestOutcome . Warning , false ) ; } } else { TraceMessage ( " " + Thread . CurrentThread . GetApartmentState ( ) . ToString ( ) ) ; } InitHostSession ( ) ; }
ITestAdapter method: called to initialize run context for this adapter.
ITestAdapter method : called to initialize run context for this adapter .
// Base param name is incorrect. // TODO: consider more reliable mechanism for hadling VS being busy. Com message filter is only for STA/same thread. // Install COM message filter to retry COM calls when VS IDE is busy, e.g. when getting the addin from VS IDE. // This prevents RPC_E_CALL_REJECTED error when VS IDE is busy. // Ignore the exception, continue without the filter.
runContext
IRunContext
The run context to be used for this run
The run context to be used for this run