Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MockHost(BuildParameters buildParameters)
        {
            _buildParameters = buildParameters;

            _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false);

            _configCache = new ConfigCache();
            ((IBuildComponent)_configCache).InitializeComponent(this);

            // We are a logging service
            _loggingService = this;

            _legacyThreadingData = new LegacyThreadingData();

            _requestEngine = new BuildRequestEngine();
            ((IBuildComponent)_requestEngine).InitializeComponent(this);

            _resultsCache = new ResultsCache();
            ((IBuildComponent)_resultsCache).InitializeComponent(this);

            _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder();
            ((IBuildComponent)_requestBuilder).InitializeComponent(this);

            _targetBuilder = new TestTargetBuilder();
            ((IBuildComponent)_targetBuilder).InitializeComponent(this);
        }
Beispiel #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode(
#if !FEATURE_NAMED_PIPES_FULL_DUPLEX
            string clientToServerPipeHandle,
            string serverToClientPipeHandle
#endif
            )
        {
            s_isOutOfProcNode = true;

#if FEATURE_APPDOMAIN_UNHANDLED_EXCEPTION
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);
#endif

#if !FEATURE_NAMED_PIPES_FULL_DUPLEX
            _clientToServerPipeHandle = clientToServerPipeHandle;
            _serverToClientPipeHandle = serverToClientPipeHandle;
#endif

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets     = new ConcurrentQueue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine  = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache   = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node
            OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket);

            ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance);

            _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService;

            if (s_projectRootElementCache == null)
            {
                s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException         += new EngineExceptionDelegate(OnEngineException);
            _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _buildRequestEngine.OnRequestBlocked          += new RequestBlockedDelegate(OnNewRequest);
            _buildRequestEngine.OnRequestComplete         += new RequestCompleteDelegate(OnRequestComplete);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResolverResponse.FactoryForDeserialization, _sdkResolverService as INodePacketHandler);
        }
Beispiel #3
0
 private void ConfigureEngine(IBuildRequestEngine engine)
 {
     engine.OnNewConfigurationRequest += this.Engine_NewConfigurationRequest;
     engine.OnRequestBlocked          += this.Engine_NewRequest;
     engine.OnRequestComplete         += this.Engine_RequestComplete;
     engine.OnRequestResumed          += this.Engine_RequestResumed;
     engine.OnStatusChanged           += this.Engine_EngineStatusChanged;
     engine.OnEngineException         += this.Engine_Exception;
 }
Beispiel #4
0
        /// <summary>
        /// Shuts down the component. First shutdown the request engine. Then shutdown the remaining of the component.
        /// Check if the test data provider exists before shutting it down as it may not have been registered yet because this is also
        /// called in TearDown and teardown is called if an exception is received.
        /// </summary>
        public void ShutdownComponent()
        {
            ShutDownRequestEngine();
            if (_testDataProvider != null)
            {
                ((IBuildComponent)_testDataProvider).ShutdownComponent();
            }

            _buildComponents.Clear();
            _loggingService = null;
            _requestEngine  = null;
        }
Beispiel #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 internal QAMockHost(GetComponentDelegate getComponentCallback)
 {
     this.buildParameters          = new BuildParameters();
     this.getComponentCallback     = getComponentCallback;
     this.engineStatusChangedEvent = new AutoResetEvent(false);
     this.lastEngineStatus         = BuildRequestEngineStatus.Shutdown;
     this.loggingService           = this;
     this.requestEngine            = null;
     this.testDataProvider         = null;
     this.buildComponents          = new Queue <IBuildComponent>();
     this.legacyThreadingData      = new LegacyThreadingData();
 }
Beispiel #6
0
        /// <summary>
        /// Shuts down the component. First shutdown the request engine. Then shutdown the remaining of the component.
        /// Check if the test data provider exists before shutting it down as it may not have been registered yet because this is also
        /// called in TearDown and teardown is called if an exception is received.
        /// </summary>
        public void ShutdownComponent()
        {
            ShutDownRequestEngine();
            if (this.testDataProvider != null)
            {
                ((IBuildComponent)this.testDataProvider).ShutdownComponent();
            }

            this.buildComponents.Clear();
            this.loggingService = null;
            this.requestEngine  = null;
        }
Beispiel #7
0
        private void VerifyEngineStatus(BuildRequestEngineStatus expectedStatus)
        {
            IBuildRequestEngine engine = (IBuildRequestEngine)_host.GetComponent(BuildComponentType.RequestEngine);

            if (engine.Status == expectedStatus)
            {
                return;
            }

            WaitForEvent(_engineStatusChangedEvent, "EngineStatusChanged");
            BuildRequestEngineStatus engineStatus = engine.Status;

            Assert.Equal(expectedStatus, engineStatus);
        }
Beispiel #8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public InProcNode(IBuildComponentHost componentHost, INodeEndpoint inProcNodeEndpoint)
        {
            _componentHost       = componentHost;
            _nodeEndpoint        = inProcNodeEndpoint;
            _receivedPackets     = new ConcurrentQueue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new AutoResetEvent(false);

            _buildRequestEngine = componentHost.GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;

            _engineExceptionEventHandler         = OnEngineException;
            _newConfigurationRequestEventHandler = OnNewConfigurationRequest;
            _requestBlockedEventHandler          = OnNewRequest;
            _requestCompleteEventHandler         = OnRequestComplete;
        }
Beispiel #9
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public InProcNode(IBuildComponentHost componentHost, INodeEndpoint inProcNodeEndpoint)
        {
            _componentHost       = componentHost;
            _nodeEndpoint        = inProcNodeEndpoint;
            _receivedPackets     = new Queue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new AutoResetEvent(false);

            _configurationProjectsLoaded = new HashSet <NGen <int> >();

            _buildRequestEngine = componentHost.GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;

            _engineExceptionEventHandler         = new EngineExceptionDelegate(OnEngineException);
            _newConfigurationRequestEventHandler = new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _requestBlockedEventHandler          = new RequestBlockedDelegate(OnNewRequest);
            _requestCompleteEventHandler         = new RequestCompleteDelegate(OnRequestComplete);
        }
Beispiel #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode()
        {
            s_isOutOfProcNode = true;

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets     = new ConcurrentQueue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine  = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache   = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node
            OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket);

            ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance);

            _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService;

            if (s_projectRootElementCacheBase == null)
            {
                s_projectRootElementCacheBase = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException         += OnEngineException;
            _buildRequestEngine.OnNewConfigurationRequest += OnNewConfigurationRequest;
            _buildRequestEngine.OnRequestBlocked          += OnNewRequest;
            _buildRequestEngine.OnRequestComplete         += OnRequestComplete;
            _buildRequestEngine.OnResourceRequest         += OnResourceRequest;

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResourceResponse, ResourceResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResult.FactoryForDeserialization, _sdkResolverService as INodePacketHandler);
        }
Beispiel #11
0
        public BuildRequestEngine_Tests()
        {
            _host                     = new MockHost();
            _nodeRequestId            = 1;
            _globalRequestId          = 1;
            _engineStatusChangedEvent = new AutoResetEvent(false);
            _requestCompleteEvent     = new AutoResetEvent(false);
            _requestResumedEvent      = new AutoResetEvent(false);
            _newRequestEvent          = new AutoResetEvent(false);
            _newConfigurationEvent    = new AutoResetEvent(false);
            _engineExceptionEvent     = new AutoResetEvent(false);

            _engine = (IBuildRequestEngine)_host.GetComponent(BuildComponentType.RequestEngine);
            _cache  = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);

            ConfigureEngine(_engine);
        }
Beispiel #12
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode()
        {
            s_isOutOfProcNode = true;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets     = new Queue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine  = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache   = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            if (s_projectRootElementCache == null)
            {
                s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException         += new EngineExceptionDelegate(OnEngineException);
            _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _buildRequestEngine.OnRequestBlocked          += new RequestBlockedDelegate(OnNewRequest);
            _buildRequestEngine.OnRequestComplete         += new RequestCompleteDelegate(OnRequestComplete);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);
        }
Beispiel #13
0
        /// <summary>
        /// Constructor allows you to set the filname, toolsversion, targets to build, build properties and execution time.
        /// Following are the defaults:
        /// ToolsVersion = "ToolsVersion"
        /// GlobalProperties = new BuildPropertyGroup()
        /// ExecutionTime = 0;
        /// Targets to build = "target1"
        /// </summary>
        public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary <ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host, bool noTargetsToBuild)
        {
            if (noTargetsToBuild || targets == null)
            {
                this.targetsToBuild = new string[] { };
            }
            else
            {
                this.targetsToBuild = targets;
            }

            this.globalProperties = ((properties == null) ? new PropertyDictionary <ProjectPropertyInstance>() : properties);
            this.toolsVersion     = ((toolsVersion == null) ? RequestDefinition.defaultToolsVersion : toolsVersion);
            this.fileName         = fileName;
            if (childDefinitions != null)
            {
                this.childDefinitions = new List <RequestDefinition>(childDefinitions);
                foreach (RequestDefinition bd in childDefinitions)
                {
                    this.childDefinitions.Add(bd);
                }
            }
            else
            {
                this.childDefinitions = new List <RequestDefinition>();
            }

            this.testProjectCompletedEvent = new AutoResetEvent(false);
            this.executionTime             = executionTime;
            this.requestEngine             = (IBuildRequestEngine)host.GetComponent(BuildComponentType.RequestEngine);
            this.testDataProvider          = (ITestDataProvider)host.GetComponent(BuildComponentType.TestDataProvider);
            this.resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
            this.testDataProvider.AddDefinition(this);
            this.projectDefinition = new ProjectDefinition(this.fileName);
            this.waitForCancel     = false;
        }
        public BuildRequestEngine_Tests()
        {
            _host = new MockHost();
            _nodeRequestId = 1;
            _globalRequestId = 1;
            _engineStatusChangedEvent = new AutoResetEvent(false);
            _requestCompleteEvent = new AutoResetEvent(false);
            _requestResumedEvent = new AutoResetEvent(false);
            _newRequestEvent = new AutoResetEvent(false);
            _newConfigurationEvent = new AutoResetEvent(false);
            _engineExceptionEvent = new AutoResetEvent(false);

            _engine = (IBuildRequestEngine)_host.GetComponent(BuildComponentType.RequestEngine);
            _cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);

            ConfigureEngine(_engine);
        }
Beispiel #15
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public InProcNode(IBuildComponentHost componentHost, INodeEndpoint inProcNodeEndpoint)
        {
            _componentHost = componentHost;
            _nodeEndpoint = inProcNodeEndpoint;
            _receivedPackets = new Queue<INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent = new AutoResetEvent(false);

            _configurationProjectsLoaded = new HashSet<NGen<int>>();

            _buildRequestEngine = componentHost.GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;

            _engineExceptionEventHandler = new EngineExceptionDelegate(OnEngineException);
            _newConfigurationRequestEventHandler = new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _requestBlockedEventHandler = new RequestBlockedDelegate(OnNewRequest);
            _requestCompleteEventHandler = new RequestCompleteDelegate(OnRequestComplete);
        }
Beispiel #16
0
        /// <summary>
        /// Constructor allows you to set the filname, toolsversion, targets to build, build properties and execution time.
        /// Following are the defaults:
        /// ToolsVersion = "ToolsVersion"
        /// GlobalProperties = new BuildPropertyGroup()
        /// ExecutionTime = 0;
        /// Targets to build = "target1"
        /// </summary>
        public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary<ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host, bool noTargetsToBuild)
        {
            if (noTargetsToBuild || targets == null)
            {
                _targetsToBuild = new string[] { };
            }
            else
            {
                _targetsToBuild = targets;
            }

            _globalProperties = ((properties == null) ? new PropertyDictionary<ProjectPropertyInstance>() : properties);
            _toolsVersion = ((toolsVersion == null) ? RequestDefinition.defaultToolsVersion : toolsVersion);
            _fileName = fileName;
            if (childDefinitions != null)
            {
                _childDefinitions = new List<RequestDefinition>(childDefinitions);
                foreach (RequestDefinition bd in childDefinitions)
                {
                    _childDefinitions.Add(bd);
                }
            }
            else
            {
                _childDefinitions = new List<RequestDefinition>();
            }

            _testProjectCompletedEvent = new AutoResetEvent(false);
            _executionTime = executionTime;
            _requestEngine = (IBuildRequestEngine)host.GetComponent(BuildComponentType.RequestEngine);
            _testDataProvider = (ITestDataProvider)host.GetComponent(BuildComponentType.TestDataProvider);
            _resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
            _testDataProvider.AddDefinition(this);
            _projectDefinition = new ProjectDefinition(_fileName);
            _waitForCancel = false;
        }
 private void ConfigureEngine(IBuildRequestEngine engine)
 {
     engine.OnNewConfigurationRequest += this.Engine_NewConfigurationRequest;
     engine.OnRequestBlocked += this.Engine_NewRequest;
     engine.OnRequestComplete += this.Engine_RequestComplete;
     engine.OnRequestResumed += this.Engine_RequestResumed;
     engine.OnStatusChanged += this.Engine_EngineStatusChanged;
     engine.OnEngineException += this.Engine_Exception;
 }
Beispiel #18
0
 /// <summary>
 /// Constructor 
 /// </summary>
 internal QAMockHost(GetComponentDelegate getComponentCallback)
 {
     this.buildParameters = new BuildParameters();
     this.getComponentCallback = getComponentCallback;
     this.engineStatusChangedEvent = new AutoResetEvent(false);
     this.lastEngineStatus = BuildRequestEngineStatus.Shutdown;
     this.loggingService = this;
     this.requestEngine = null;
     this.testDataProvider = null;
     this.buildComponents = new Queue<IBuildComponent>();
     this.legacyThreadingData = new LegacyThreadingData();
 }
Beispiel #19
0
        /// <summary>
        /// Constructs and returns a component of the specified type.
        /// </summary>
        public IBuildComponent GetComponent(BuildComponentType type)
        {
            IBuildComponent returnComponent = null;

            switch(type)
            {
                case BuildComponentType.LoggingService: // Singleton
                    return (IBuildComponent)this.loggingService;

                case BuildComponentType.TestDataProvider: // Singleton
                    if (this.testDataProvider != null)
                    {
                        return (IBuildComponent)this.testDataProvider;
                    }

                    returnComponent = this.getComponentCallback(type);
                    if (returnComponent != null)
                    {
                        returnComponent.InitializeComponent(this);
                        this.testDataProvider = (ITestDataProvider)returnComponent;
                    }

                    break;

                case BuildComponentType.RequestEngine: // Singleton
                    if (this.requestEngine != null)
                    {
                        return (IBuildComponent)this.requestEngine;
                    }

                    returnComponent = this.getComponentCallback(type);
                    if (returnComponent != null)
                    {
                        returnComponent.InitializeComponent(this);
                        this.requestEngine = (IBuildRequestEngine)returnComponent;
                        this.requestEngine.OnEngineException += new EngineExceptionDelegate(RequestEngine_OnEngineException);
                        this.requestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(RequestEngine_OnNewConfigurationRequest);
                        this.requestEngine.OnRequestBlocked += new RequestBlockedDelegate(RequestEngine_OnNewRequest);
                        this.requestEngine.OnRequestComplete += new RequestCompleteDelegate(RequestEngine_OnRequestComplete);
                        this.requestEngine.OnStatusChanged += new EngineStatusChangedDelegate(RequestEngine_OnStatusChanged);
                    }

                    break;

                default:
                    returnComponent = this.getComponentCallback(type);
                    if (returnComponent != null)
                    {
                        returnComponent.InitializeComponent(this);
                    }
                    break;
            }

            if (returnComponent != null)
            {
                lock (this.buildComponents)
                {
                    this.buildComponents.Enqueue(returnComponent);
                }
            }

            return returnComponent;
        }
Beispiel #20
0
        /// <summary>
        /// Constructs and returns a component of the specified type.
        /// </summary>
        public IBuildComponent GetComponent(BuildComponentType type)
        {
            IBuildComponent returnComponent = null;

            switch (type)
            {
            case BuildComponentType.LoggingService:     // Singleton
                return((IBuildComponent)this.loggingService);

            case BuildComponentType.TestDataProvider:     // Singleton
                if (this.testDataProvider != null)
                {
                    return((IBuildComponent)this.testDataProvider);
                }

                returnComponent = this.getComponentCallback(type);
                if (returnComponent != null)
                {
                    returnComponent.InitializeComponent(this);
                    this.testDataProvider = (ITestDataProvider)returnComponent;
                }

                break;

            case BuildComponentType.RequestEngine:     // Singleton
                if (this.requestEngine != null)
                {
                    return((IBuildComponent)this.requestEngine);
                }

                returnComponent = this.getComponentCallback(type);
                if (returnComponent != null)
                {
                    returnComponent.InitializeComponent(this);
                    this.requestEngine = (IBuildRequestEngine)returnComponent;
                    this.requestEngine.OnEngineException         += new EngineExceptionDelegate(RequestEngine_OnEngineException);
                    this.requestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(RequestEngine_OnNewConfigurationRequest);
                    this.requestEngine.OnRequestBlocked          += new RequestBlockedDelegate(RequestEngine_OnNewRequest);
                    this.requestEngine.OnRequestComplete         += new RequestCompleteDelegate(RequestEngine_OnRequestComplete);
                    this.requestEngine.OnStatusChanged           += new EngineStatusChangedDelegate(RequestEngine_OnStatusChanged);
                }

                break;

            default:
                returnComponent = this.getComponentCallback(type);
                if (returnComponent != null)
                {
                    returnComponent.InitializeComponent(this);
                }
                break;
            }

            if (returnComponent != null)
            {
                lock (this.buildComponents)
                {
                    this.buildComponents.Enqueue(returnComponent);
                }
            }

            return(returnComponent);
        }
Beispiel #21
0
        /// <summary>
        /// Shuts down the component. First shutdown the request engine. Then shutdown the remaining of the component.
        /// Check if the test data provider exists before shutting it down as it may not have been registered yet because this is also
        /// called in TearDown and teardown is called if an exception is received.
        /// </summary>
        public void ShutdownComponent()
        {
            ShutDownRequestEngine();
            if (this.testDataProvider != null)
            {
                ((IBuildComponent)this.testDataProvider).ShutdownComponent();
            }

            this.buildComponents.Clear();
            this.loggingService = null;
            this.requestEngine = null;
        }
Beispiel #22
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode()
        {
            s_isOutOfProcNode = true;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets = new Queue<INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            if (s_projectRootElementCache == null)
            {
                s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException);
            _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest);
            _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);
        }
Beispiel #23
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MockHost(BuildParameters buildParameters)
        {
            _buildParameters = buildParameters;

            _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false);

            _configCache = new ConfigCache();
            ((IBuildComponent)_configCache).InitializeComponent(this);

            // We are a logging service
            _loggingService = this;

            _legacyThreadingData = new LegacyThreadingData();

            _requestEngine = new BuildRequestEngine();
            ((IBuildComponent)_requestEngine).InitializeComponent(this);

            _resultsCache = new ResultsCache();
            ((IBuildComponent)_resultsCache).InitializeComponent(this);

            _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder();
            ((IBuildComponent)_requestBuilder).InitializeComponent(this);

            _targetBuilder = new TestTargetBuilder();
            ((IBuildComponent)_targetBuilder).InitializeComponent(this);
        }
Beispiel #24
0
        /// <summary>
        /// Shuts down the component. First shutdown the request engine. Then shutdown the remaining of the component.
        /// Check if the test data provider exists before shutting it down as it may not have been registered yet because this is also
        /// called in TearDown and teardown is called if an exception is received.
        /// </summary>
        public void ShutdownComponent()
        {
            ShutDownRequestEngine();
            if (_testDataProvider != null)
            {
                ((IBuildComponent)_testDataProvider).ShutdownComponent();
            }

            _buildComponents.Clear();
            _loggingService = null;
            _requestEngine = null;
        }