/// <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); }
/// <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); }
/// <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(); }
/// <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); }
/// <summary> /// Starts the request and blocks until results are available. /// </summary> /// <exception cref="System.InvalidOperationException">The request has already been started or is already complete.</exception> public BuildResult Execute() { LegacyThreadingData legacyThreadingData = ((IBuildComponentHost)BuildManager).LegacyThreadingData; legacyThreadingData.RegisterSubmissionForLegacyThread(this.SubmissionId); ExecuteAsync(null, null, _legacyThreadingSemantics); if (_legacyThreadingSemantics) { RequestBuilder.WaitWithBuilderThreadStart(new WaitHandle[] { WaitHandle }, false, legacyThreadingData, this.SubmissionId); } else { WaitHandle.WaitOne(); } legacyThreadingData.UnregisterSubmissionForLegacyThread(this.SubmissionId); return(BuildResult); }
/// <summary> /// Constructor /// /// UNDONE: Refactor this, and the other MockHosts, to use a common base implementation. The duplication of the /// logging implementation alone is unfortunate. /// </summary> public MockHost() { _buildParameters = new BuildParameters(); _legacyThreadingData = new LegacyThreadingData(); _configCache = new ConfigCache(); ((IBuildComponent)_configCache).InitializeComponent(this); _loggingService = this; _resultsCache = new ResultsCache(); ((IBuildComponent)_resultsCache).InitializeComponent(this); _requestBuilder = new RequestBuilder(); ((IBuildComponent)_requestBuilder).InitializeComponent(this); _targetBuilder = new TargetBuilder(); ((IBuildComponent)_targetBuilder).InitializeComponent(this); _sdkResolverService = new MockSdkResolverService(); ((IBuildComponent)_sdkResolverService).InitializeComponent(this); }
/// <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); }
public MockHost() { _buildParameters = new BuildParameters(); _dataReceivedEvent = new AutoResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); }
/// <summary> /// Constructor /// /// UNDONE: Refactor this, and the other MockHosts, to use a common base implementation. The duplication of the /// logging implementation alone is unfortunate. /// </summary> public MockHost() { _buildParameters = new BuildParameters(); _legacyThreadingData = new LegacyThreadingData(); _configCache = new ConfigCache(); ((IBuildComponent)_configCache).InitializeComponent(this); _loggingService = this; _resultsCache = new ResultsCache(); ((IBuildComponent)_resultsCache).InitializeComponent(this); _requestBuilder = new RequestBuilder(); ((IBuildComponent)_requestBuilder).InitializeComponent(this); _targetBuilder = new TargetBuilder(); ((IBuildComponent)_targetBuilder).InitializeComponent(this); }
/// <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(); }
/// <summary> /// This method waits for the specified handles, but will also spawn a request builder "thread" if that event is set. /// This mechanism is used to implement running RequestBuilder threads on the main UI thread in VS. /// </summary> /// <returns>The index of the handle which was signaled.</returns> internal static int WaitWithBuilderThreadStart(WaitHandle[] handles, bool recursive, LegacyThreadingData threadingData, int submissionId) { WaitHandle[] allHandles = new WaitHandle[handles.Length + 1]; allHandles[0] = threadingData.GetStartRequestBuilderMainThreadEventForSubmission(submissionId); Array.Copy(handles, 0, allHandles, 1, handles.Length); while (true) { try { int signaledIndex = WaitHandle.WaitAny(allHandles, Timeout.Infinite); if (signaledIndex == 0) { // Grab the request builder reserved for running on this thread. RequestBuilder builder = threadingData.InstanceForMainThread; // This clears out the value so we can re-enter with legacy-threading semantics on another request builder // which must use this same thread. It is safe to perform this operation because request activations cannot // happen in parallel on the same thread, so there is no race. threadingData.InstanceForMainThread = null; // Now wait for the request to build. builder.RequestThreadProc(setThreadParameters: false).Wait(); } else { // We were signalled on one of the other handles. Return control to the caller. return signaledIndex - 1; } } finally { // If this was the top level submission doing the waiting, we are done with this submission and it's // main thread building context if (!recursive) { // Set the event indicating the legacy thread is no longer being used, so it is safe to clean up. threadingData.SignalLegacyThreadEnd(submissionId); } } } }
/// <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); }