/Microsoft.Build/Microsoft.Build/Microsoft/Build/BackEnd/RequestBuilder.cs
C# | 671 lines | 638 code | 33 blank | 0 comment | 109 complexity | a1441d8d0d1d4af9d32bcf53c0483534 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
- namespace Microsoft.Build.BackEnd
- {
- using Microsoft.Build.BackEnd.Logging;
- using Microsoft.Build.Collections;
- using Microsoft.Build.Evaluation;
- using Microsoft.Build.Exceptions;
- using Microsoft.Build.Execution;
- using Microsoft.Build.Framework;
- using Microsoft.Build.Internal;
- using Microsoft.Build.Shared;
- using Microsoft.Internal.Performance;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Runtime;
- using System.Threading;
-
- internal class RequestBuilder : IRequestBuilder, IRequestBuilderCallback, IBuildComponent
- {
- private BlockType blockType = BlockType.Unblocked;
- private object buildStateLock = new object();
- private IBuildComponentHost componentHost;
- private AutoResetEvent continueEvent = new AutoResetEvent(false);
- private IDictionary<int, BuildResult> continueResults;
- private NodeLoggingContext nodeLoggingContext;
- private BuildRequestBlockedDelegate OnBuildRequestBlocked;
- private BuildRequestCompletedDelegate OnBuildRequestCompleted;
- private NewBuildRequestsDelegate OnNewBuildRequests;
- private ProjectLoggingContext projectLoggingContext;
- private ManualResetEvent requestBuilderIdle = new ManualResetEvent(true);
- private BuildRequestEntry requestEntry;
- private Thread requestThread;
- private string savedCurrentDirectory;
- private IDictionary<string, string> savedEnvironmentVariables;
- private AutoResetEvent shutdownThreadEvent = new AutoResetEvent(false);
- private AutoResetEvent startBuildingEvent = new AutoResetEvent(false);
- private ITargetBuilder targetBuilder;
- private ManualResetEvent terminateEvent = new ManualResetEvent(false);
-
- public event BuildRequestBlockedDelegate OnBuildRequestBlocked
- {
- add
- {
- BuildRequestBlockedDelegate delegate3;
- BuildRequestBlockedDelegate onBuildRequestBlocked = this.OnBuildRequestBlocked;
- do
- {
- delegate3 = onBuildRequestBlocked;
- BuildRequestBlockedDelegate delegate4 = (BuildRequestBlockedDelegate) Delegate.Combine(delegate3, value);
- onBuildRequestBlocked = Interlocked.CompareExchange<BuildRequestBlockedDelegate>(ref this.OnBuildRequestBlocked, delegate4, delegate3);
- }
- while (onBuildRequestBlocked != delegate3);
- }
- remove
- {
- BuildRequestBlockedDelegate delegate3;
- BuildRequestBlockedDelegate onBuildRequestBlocked = this.OnBuildRequestBlocked;
- do
- {
- delegate3 = onBuildRequestBlocked;
- BuildRequestBlockedDelegate delegate4 = (BuildRequestBlockedDelegate) Delegate.Remove(delegate3, value);
- onBuildRequestBlocked = Interlocked.CompareExchange<BuildRequestBlockedDelegate>(ref this.OnBuildRequestBlocked, delegate4, delegate3);
- }
- while (onBuildRequestBlocked != delegate3);
- }
- }
-
- public event BuildRequestCompletedDelegate OnBuildRequestCompleted
- {
- add
- {
- BuildRequestCompletedDelegate delegate3;
- BuildRequestCompletedDelegate onBuildRequestCompleted = this.OnBuildRequestCompleted;
- do
- {
- delegate3 = onBuildRequestCompleted;
- BuildRequestCompletedDelegate delegate4 = (BuildRequestCompletedDelegate) Delegate.Combine(delegate3, value);
- onBuildRequestCompleted = Interlocked.CompareExchange<BuildRequestCompletedDelegate>(ref this.OnBuildRequestCompleted, delegate4, delegate3);
- }
- while (onBuildRequestCompleted != delegate3);
- }
- remove
- {
- BuildRequestCompletedDelegate delegate3;
- BuildRequestCompletedDelegate onBuildRequestCompleted = this.OnBuildRequestCompleted;
- do
- {
- delegate3 = onBuildRequestCompleted;
- BuildRequestCompletedDelegate delegate4 = (BuildRequestCompletedDelegate) Delegate.Remove(delegate3, value);
- onBuildRequestCompleted = Interlocked.CompareExchange<BuildRequestCompletedDelegate>(ref this.OnBuildRequestCompleted, delegate4, delegate3);
- }
- while (onBuildRequestCompleted != delegate3);
- }
- }
-
- public event NewBuildRequestsDelegate OnNewBuildRequests
- {
- add
- {
- NewBuildRequestsDelegate delegate3;
- NewBuildRequestsDelegate onNewBuildRequests = this.OnNewBuildRequests;
- do
- {
- delegate3 = onNewBuildRequests;
- NewBuildRequestsDelegate delegate4 = (NewBuildRequestsDelegate) Delegate.Combine(delegate3, value);
- onNewBuildRequests = Interlocked.CompareExchange<NewBuildRequestsDelegate>(ref this.OnNewBuildRequests, delegate4, delegate3);
- }
- while (onNewBuildRequests != delegate3);
- }
- remove
- {
- NewBuildRequestsDelegate delegate3;
- NewBuildRequestsDelegate onNewBuildRequests = this.OnNewBuildRequests;
- do
- {
- delegate3 = onNewBuildRequests;
- NewBuildRequestsDelegate delegate4 = (NewBuildRequestsDelegate) Delegate.Remove(delegate3, value);
- onNewBuildRequests = Interlocked.CompareExchange<NewBuildRequestsDelegate>(ref this.OnNewBuildRequests, delegate4, delegate3);
- }
- while (onNewBuildRequests != delegate3);
- }
- }
-
- internal RequestBuilder()
- {
- }
-
- public void BlockOnTargetInProgress(int blockingGlobalRequestId, string blockingTarget)
- {
- this.SaveOperatingEnvironment();
- this.blockType = BlockType.BlockedOnTargetInProgress;
- this.RaiseOnBlockedRequest(blockingGlobalRequestId, blockingTarget);
- int num = WaitHandle.WaitAny(new WaitHandle[] { this.shutdownThreadEvent, this.terminateEvent, this.continueEvent });
- this.RestoreOperatingEnvironment();
- switch (num)
- {
- case 0:
- case 1:
- throw new BuildAbortedException();
- }
- this.blockType = BlockType.Unblocked;
- this.VerifyEntryInActiveState();
- }
-
- private void BuildAndReport()
- {
- Exception exception = null;
- BuildResult result = null;
- try
- {
- this.VerifyEntryInActiveState();
- result = this.BuildProject();
- }
- catch (InvalidProjectFileException exception2)
- {
- if (this.projectLoggingContext != null)
- {
- this.projectLoggingContext.LogInvalidProjectFileError(exception2);
- }
- else
- {
- this.nodeLoggingContext.LogInvalidProjectFileError(exception2);
- }
- exception = exception2;
- }
- catch (LoggerException exception3)
- {
- exception = exception3;
- }
- catch (InternalLoggerException exception4)
- {
- exception = exception4;
- }
- catch (ThreadAbortException)
- {
- exception = new BuildAbortedException();
- Thread.ResetAbort();
- }
- catch (Exception exception5)
- {
- exception = exception5;
- if (ExceptionHandling.IsCriticalException(exception5))
- {
- throw;
- }
- }
- finally
- {
- lock (this.buildStateLock)
- {
- this.blockType = BlockType.Unblocked;
- if (exception != null)
- {
- ErrorUtilities.VerifyThrow(result == null, "Result already set when exception was thrown.");
- result = new BuildResult(this.requestEntry.Request, exception);
- }
- if (this.projectLoggingContext != null)
- {
- this.projectLoggingContext.LogProjectFinished(result.OverallResult == BuildResultCode.Success);
- }
- BuildRequestEntry requestEntry = this.requestEntry;
- this.nodeLoggingContext = null;
- this.requestEntry = null;
- this.targetBuilder = null;
- this.requestBuilderIdle.Set();
- requestEntry.Complete(result);
- this.RaiseBuildRequestCompleted(requestEntry);
- }
- }
- }
-
- private BuildResult BuildProject()
- {
- ErrorUtilities.VerifyThrow(this.targetBuilder != null, "Target builder is null");
- this.projectLoggingContext = null;
- try
- {
- if (!this.requestEntry.RequestConfiguration.IsLoaded)
- {
- this.LoadProjectIntoConfiguration();
- }
- }
- catch
- {
- this.projectLoggingContext = new ProjectLoggingContext(this.nodeLoggingContext, this.requestEntry.Request, this.requestEntry.RequestConfiguration.ProjectFullPath, this.requestEntry.RequestConfiguration.ToolsVersion, this.requestEntry.Request.ParentBuildEventContext);
- throw;
- }
- this.projectLoggingContext = this.nodeLoggingContext.LogProjectStarted(this.requestEntry);
- this.requestEntry.RequestConfiguration.RetrieveFromCache();
- if (this.requestEntry.RequestConfiguration.Project.TreatingHigherToolsVersionsAs40)
- {
- this.projectLoggingContext.LogComment(MessageImportance.High, "TreatingHigherToolsVersionAs40", new object[] { this.requestEntry.RequestConfiguration.Project.OriginalProjectToolsVersion });
- }
- this.requestEntry.Request.BuildEventContext = this.projectLoggingContext.BuildEventContext;
- string[] targets = this.requestEntry.RequestConfiguration.GetTargetsUsedToBuildRequest(this.requestEntry.Request).ToArray();
- ProjectErrorUtilities.VerifyThrowInvalidProject(targets.Length > 0, this.requestEntry.RequestConfiguration.Project.ProjectFileLocation, "NoTargetSpecified");
- this.SetProjectCurrentDirectory();
- return this.targetBuilder.BuildTargets(this.projectLoggingContext, this.requestEntry, this, targets, this.requestEntry.RequestConfiguration.BaseLookup);
- }
-
- public BuildResult[] BuildProjects(string[] projectFiles, PropertyDictionary<ProjectPropertyInstance>[] properties, string[] toolsVersions, string[] targets, bool waitForResults)
- {
- ErrorUtilities.VerifyThrowArgumentNull(projectFiles, "projectFiles");
- ErrorUtilities.VerifyThrowArgumentNull(properties, "properties");
- ErrorUtilities.VerifyThrowArgumentNull(targets, "targets");
- ErrorUtilities.VerifyThrowArgumentNull(toolsVersions, "toolsVersions");
- ErrorUtilities.VerifyThrow(this.componentHost != null, "No host object set");
- ErrorUtilities.VerifyThrow(projectFiles.Length == properties.Length, "Properties and project counts not the same");
- ErrorUtilities.VerifyThrow(projectFiles.Length == toolsVersions.Length, "Tools versions and project counts not the same");
- FullyQualifiedBuildRequest[] requests = new FullyQualifiedBuildRequest[projectFiles.Length];
- for (int i = 0; i < projectFiles.Length; i++)
- {
- if (!Path.IsPathRooted(projectFiles[i]))
- {
- projectFiles[i] = Path.Combine(this.requestEntry.ProjectRootDirectory, projectFiles[i]);
- }
- projectFiles[i] = FileUtilities.NormalizePath(projectFiles[i]);
- string toolsVersion = toolsVersions[i];
- if ((toolsVersion == null) && this.requestEntry.RequestConfiguration.ExplicitToolsVersionSpecified)
- {
- toolsVersion = this.requestEntry.RequestConfiguration.ToolsVersion;
- }
- BuildRequestData data = new BuildRequestData(projectFiles[i], properties[i].ToDictionary(), toolsVersion, targets, null);
- BuildRequestConfiguration config = new BuildRequestConfiguration(data, this.componentHost.BuildParameters.DefaultToolsVersion);
- requests[i] = new FullyQualifiedBuildRequest(config, targets, waitForResults);
- }
- List<BuildResult> list = new List<BuildResult>(this.StartNewBuildRequests(requests).Values);
- list.Sort(delegate (BuildResult left, BuildResult right) {
- if (left.NodeRequestId < right.NodeRequestId)
- {
- return -1;
- }
- if (left.NodeRequestId == right.NodeRequestId)
- {
- return 0;
- }
- return 1;
- });
- return list.ToArray();
- }
-
- public void BuildRequest(NodeLoggingContext loggingContext, BuildRequestEntry entry)
- {
- lock (this.buildStateLock)
- {
- ErrorUtilities.VerifyThrowArgumentNull(loggingContext, "loggingContext");
- ErrorUtilities.VerifyThrowArgumentNull(entry, "entry");
- ErrorUtilities.VerifyThrow(null != this.componentHost, "Host not set.");
- ErrorUtilities.VerifyThrow(this.requestBuilderIdle.WaitOne(0, false), "Build in progress.");
- ErrorUtilities.VerifyThrow(this.targetBuilder == null, "targetBuilder not null");
- ErrorUtilities.VerifyThrow(this.nodeLoggingContext == null, "nodeLoggingContext not null");
- ErrorUtilities.VerifyThrow(this.requestEntry == null, "requestEntry not null");
- this.nodeLoggingContext = loggingContext;
- this.blockType = BlockType.Unblocked;
- this.requestEntry = entry;
- this.requestEntry.Continue();
- this.targetBuilder = (ITargetBuilder) this.componentHost.GetComponent(BuildComponentType.TargetBuilder);
- this.VerifyEntryInActiveState();
- if (this.componentHost.BuildParameters.LegacyThreadingSemantics && (this.componentHost.LegacyThreadingData.MainThreadSubmissionId == this.requestEntry.Request.SubmissionId))
- {
- if (this.requestThread != null)
- {
- this.shutdownThreadEvent.Set();
- this.requestThread.Join();
- this.requestThread = null;
- }
- this.continueResults = null;
- this.componentHost.LegacyThreadingData.InstanceForMainThread = this;
- this.componentHost.LegacyThreadingData.StartNewRequestBuilderMainThreadEvent.Set();
- }
- else
- {
- if (this.requestThread == null)
- {
- this.requestThread = new Thread(new ThreadStart(this.RequestThreadProc));
- this.requestThread.Name = "RequestBuilder thread";
- this.requestThread.IsBackground = true;
- this.requestThread.Priority = this.componentHost.BuildParameters.BuildThreadPriority;
- if (Environment.GetEnvironmentVariable("MSBUILDFORCESTA") == "1")
- {
- this.requestThread.SetApartmentState(ApartmentState.STA);
- }
- else
- {
- this.requestThread.SetApartmentState(ApartmentState.MTA);
- }
- this.continueResults = null;
- this.requestThread.Start();
- }
- this.requestThread.CurrentCulture = this.componentHost.BuildParameters.Culture;
- this.requestThread.CurrentUICulture = this.componentHost.BuildParameters.UICulture;
- ErrorUtilities.VerifyThrow(this.requestThread.IsAlive, "RequestBuilder thread is not alive. ManagedThreadId: {0}", this.requestThread.ManagedThreadId);
- }
- this.requestBuilderIdle.Reset();
- this.startBuildingEvent.Set();
- }
- }
-
- public void CancelRequest()
- {
- ITargetBuilder targetBuilder;
- lock (this.buildStateLock)
- {
- if ((this.requestEntry == null) || (this.targetBuilder == null))
- {
- return;
- }
- ErrorUtilities.VerifyThrow((this.requestThread != null) || (this.componentHost.LegacyThreadingData.MainThreadSubmissionId != -1), "Request thread not set");
- targetBuilder = this.targetBuilder;
- ErrorUtilities.VerifyThrow(!this.terminateEvent.WaitOne(0, false), "Request already terminated");
- this.terminateEvent.Set();
- }
- try
- {
- targetBuilder.CancelRequest();
- if (!this.requestBuilderIdle.WaitOne(BuildParameters.RequestBuilderShutdownTimeout))
- {
- this.projectLoggingContext.LogError(new BuildEventFileInfo(string.Empty), "FailedToReceiveTaskThreadStatus", new object[] { BuildParameters.RequestBuilderShutdownTimeout });
- ErrorUtilities.ThrowInvalidOperation("UnableToCancel", new object[0]);
- }
- }
- finally
- {
- this.terminateEvent.Reset();
- }
- }
-
- public void ContinueRequest()
- {
- ErrorUtilities.VerifyThrow((this.requestThread != null) || (this.componentHost.LegacyThreadingData.MainThreadSubmissionId != -1), "Request not building");
- ErrorUtilities.VerifyThrow(!this.terminateEvent.WaitOne(0, false), "Request already terminated");
- ErrorUtilities.VerifyThrow(!this.continueEvent.WaitOne(0, false), "Request already continued");
- this.VerifyEntryInReadyState();
- this.continueResults = this.requestEntry.Continue();
- ErrorUtilities.VerifyThrow(((this.blockType == BlockType.BlockedOnTargetInProgress) || (this.blockType == BlockType.Yielded)) || (this.continueResults != null), "Unexpected null results for request {0} (nr {1})", this.requestEntry.Request.GlobalRequestId, this.requestEntry.Request.NodeRequestId);
- this.continueEvent.Set();
- }
-
- internal static IBuildComponent CreateComponent(BuildComponentType type)
- {
- ErrorUtilities.VerifyThrow(type == BuildComponentType.RequestBuilder, "Cannot create components of type {0}", type);
- return new RequestBuilder();
- }
-
- public void InitializeComponent(IBuildComponentHost host)
- {
- ErrorUtilities.VerifyThrowArgumentNull(host, "host");
- ErrorUtilities.VerifyThrow(this.componentHost == null, "RequestBuilder already initialized.");
- this.componentHost = host;
- }
-
- private void LoadProjectIntoConfiguration()
- {
- ErrorUtilities.VerifyThrow(this.requestEntry.RequestConfiguration.Project == null, "We've already loaded the project for this configuration id {0}.", this.requestEntry.RequestConfiguration.ConfigurationId);
- if (this.componentHost.BuildParameters.SaveOperatingEnvironment)
- {
- Directory.SetCurrentDirectory(BuildParameters.StartupDirectory);
- }
- Dictionary<string, string> globalProperties = new Dictionary<string, string>(MSBuildNameIgnoreCaseComparer.Default);
- foreach (ProjectPropertyInstance instance in this.requestEntry.RequestConfiguration.Properties)
- {
- globalProperties.Add(instance.Name, ((IProperty) instance).EvaluatedValueEscaped);
- }
- string toolsVersion = this.requestEntry.RequestConfiguration.ExplicitToolsVersionSpecified ? this.requestEntry.RequestConfiguration.ToolsVersion : null;
- this.requestEntry.RequestConfiguration.Project = new ProjectInstance(this.requestEntry.RequestConfiguration.ProjectFullPath, globalProperties, toolsVersion, this.componentHost.BuildParameters, this.nodeLoggingContext.LoggingService, this.requestEntry.Request.BuildEventContext);
- }
-
- private void RaiseBuildRequestCompleted(BuildRequestEntry entryToComplete)
- {
- BuildRequestCompletedDelegate onBuildRequestCompleted = this.OnBuildRequestCompleted;
- if (onBuildRequestCompleted != null)
- {
- onBuildRequestCompleted(entryToComplete);
- }
- }
-
- private void RaiseOnBlockedRequest(int blockingGlobalRequestId, string blockingTarget)
- {
- BuildRequestBlockedDelegate onBuildRequestBlocked = this.OnBuildRequestBlocked;
- if (onBuildRequestBlocked != null)
- {
- onBuildRequestBlocked(this.requestEntry, blockingGlobalRequestId, blockingTarget);
- }
- }
-
- private void RaiseOnNewBuildRequests(FullyQualifiedBuildRequest[] requests)
- {
- NewBuildRequestsDelegate onNewBuildRequests = this.OnNewBuildRequests;
- if (onNewBuildRequests != null)
- {
- onNewBuildRequests(this.requestEntry, requests);
- }
- }
-
- public void Reacquire()
- {
- this.RaiseOnBlockedRequest(this.requestEntry.Request.GlobalRequestId, string.Empty);
- int num = WaitHandle.WaitAny(new WaitHandle[] { this.shutdownThreadEvent, this.terminateEvent, this.continueEvent });
- this.RestoreOperatingEnvironment();
- switch (num)
- {
- case 0:
- case 1:
- throw new BuildAbortedException();
- }
- this.blockType = BlockType.Unblocked;
- this.VerifyEntryInActiveState();
- }
-
- private void RequestThreadProc()
- {
- try
- {
- bool flag = false;
- WaitHandle[] waitHandles = new WaitHandle[] { this.shutdownThreadEvent, this.startBuildingEvent };
- while (!flag)
- {
- switch (WaitHandle.WaitAny(waitHandles))
- {
- case 0:
- flag = true;
- break;
-
- case 1:
- using (new Microsoft.Internal.Performance.CodeMarkerStartEnd(Microsoft.Internal.Performance.CodeMarkerEvent.perfMSBuildEngineBuildProjectBegin, Microsoft.Internal.Performance.CodeMarkerEvent.perfMSBuildEngineBuildProjectEnd))
- {
- this.BuildAndReport();
- if (this.requestThread == null)
- {
- flag = true;
- }
- }
- break;
- }
- }
- }
- catch (ThreadAbortException)
- {
- throw;
- }
- catch (Exception exception)
- {
- ExceptionHandling.DumpExceptionToFile(exception);
- ErrorUtilities.ThrowInternalError(exception.Message, exception, new object[0]);
- throw;
- }
- }
-
- private void RestoreOperatingEnvironment()
- {
- if (this.componentHost.BuildParameters.SaveOperatingEnvironment)
- {
- ErrorUtilities.VerifyThrow(this.savedCurrentDirectory != null, "Current directory not previously saved.");
- ErrorUtilities.VerifyThrow(this.savedEnvironmentVariables != null, "Current environment not previously saved.");
- IDictionary<string, string> environmentVariables = Utilities.GetEnvironmentVariables();
- foreach (KeyValuePair<string, string> pair in environmentVariables)
- {
- if (!this.savedEnvironmentVariables.ContainsKey(pair.Key))
- {
- Environment.SetEnvironmentVariable(pair.Key, null);
- }
- }
- foreach (KeyValuePair<string, string> pair2 in this.savedEnvironmentVariables)
- {
- string str;
- if (!environmentVariables.TryGetValue(pair2.Key, out str) || !string.Equals(pair2.Value, str, StringComparison.Ordinal))
- {
- Environment.SetEnvironmentVariable(pair2.Key, pair2.Value);
- }
- }
- NativeMethodsShared.SetCurrentDirectory(this.savedCurrentDirectory);
- }
- this.savedEnvironmentVariables = null;
- this.savedCurrentDirectory = null;
- }
-
- private void SaveOperatingEnvironment()
- {
- if (this.componentHost.BuildParameters.SaveOperatingEnvironment)
- {
- this.savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory();
- this.savedEnvironmentVariables = Utilities.GetEnvironmentVariables();
- }
- }
-
- private void SetProjectCurrentDirectory()
- {
- if (this.componentHost.BuildParameters.SaveOperatingEnvironment)
- {
- NativeMethodsShared.SetCurrentDirectory(this.requestEntry.ProjectRootDirectory);
- }
- }
-
- public void ShutdownComponent()
- {
- this.shutdownThreadEvent.Set();
- if (this.requestThread != null)
- {
- ErrorUtilities.VerifyThrow(this.requestThread.Join(BuildParameters.RequestBuilderShutdownTimeout), "Request thread not terminated before shutdown.");
- }
- this.componentHost = null;
- }
-
- private IDictionary<int, BuildResult> StartNewBuildRequests(FullyQualifiedBuildRequest[] requests)
- {
- IDictionary<int, BuildResult> continueResults;
- bool flag = false;
- foreach (FullyQualifiedBuildRequest request in requests)
- {
- if (request.ResultsNeeded)
- {
- flag = true;
- break;
- }
- }
- this.blockType = BlockType.BlockedOnChildRequests;
- if (flag)
- {
- this.SaveOperatingEnvironment();
- }
- this.continueResults = null;
- this.RaiseOnNewBuildRequests(requests);
- if (flag)
- {
- int num;
- WaitHandle[] handles = new WaitHandle[] { this.shutdownThreadEvent, this.terminateEvent, this.continueEvent };
- if (this.requestThread == null)
- {
- num = WaitWithBuilderThreadStart(handles, true, this.componentHost.LegacyThreadingData);
- }
- else
- {
- num = WaitHandle.WaitAny(handles);
- }
- if (num == 2)
- {
- this.RestoreOperatingEnvironment();
- this.VerifyEntryInActiveState();
- }
- continueResults = this.continueResults;
- this.continueResults = null;
- if (continueResults == null)
- {
- ErrorUtilities.VerifyThrow((num == 0) || (num == 1), "Unexpected null results during continue");
- continueResults = new Dictionary<int, BuildResult>();
- for (int i = 0; i < requests.Length; i++)
- {
- continueResults[i] = new BuildResult(new Microsoft.Build.BackEnd.BuildRequest(), new BuildAbortedException());
- }
- }
- foreach (BuildResult result in continueResults.Values)
- {
- if (result.CircularDependency)
- {
- throw new CircularDependencyException();
- }
- }
- }
- else
- {
- continueResults = new Dictionary<int, BuildResult>();
- }
- this.blockType = BlockType.Unblocked;
- return continueResults;
- }
-
- private void VerifyEntryInActiveState()
- {
- ErrorUtilities.VerifyThrow(this.requestEntry.State == BuildRequestEntryState.Active, "Entry is not in the Active state, it is in the {0} state.", this.requestEntry.State);
- }
-
- private void VerifyEntryInReadyState()
- {
- ErrorUtilities.VerifyThrow(this.requestEntry.State == BuildRequestEntryState.Ready, "Entry is not in the Ready state, it is in the {0} state.", this.requestEntry.State);
- }
-
- internal static int WaitWithBuilderThreadStart(WaitHandle[] handles, bool recursive, LegacyThreadingData threadingData)
- {
- int num2;
- WaitHandle[] destinationArray = new WaitHandle[handles.Length + 1];
- destinationArray[0] = threadingData.StartNewRequestBuilderMainThreadEvent;
- Array.Copy(handles, 0, destinationArray, 1, handles.Length);
- Label_0020:;
- try
- {
- int num = ThreadingUtilities.WaitAnyNoMessagePump(destinationArray, -1);
- if (num == 0)
- {
- RequestBuilder instanceForMainThread = threadingData.InstanceForMainThread;
- threadingData.InstanceForMainThread = null;
- instanceForMainThread.RequestThreadProc();
- goto Label_0020;
- }
- num2 = num - 1;
- }
- finally
- {
- if (!recursive)
- {
- threadingData.MainThreadSubmissionId = -1;
- }
- }
- return num2;
- }
-
- public void Yield()
- {
- this.SaveOperatingEnvironment();
- this.blockType = BlockType.Yielded;
- this.RaiseOnBlockedRequest(this.requestEntry.Request.GlobalRequestId, null);
- }
-
- internal BuildRequestEntry RequestEntry
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.requestEntry;
- }
- }
-
- private enum BlockType
- {
- BlockedOnTargetInProgress,
- BlockedOnChildRequests,
- Yielded,
- Unblocked
- }
- }
- }
-