/Microsoft.Build/Microsoft.Build/Microsoft/Build/BackEnd/ScheduleResponse.cs
C# | 117 lines | 97 code | 20 blank | 0 comment | 2 complexity | a96cdbbfa484b1a24d8dac12b585be47 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
- namespace Microsoft.Build.BackEnd
- {
- using Microsoft.Build.Execution;
- using System;
- using System.Globalization;
- using System.Runtime;
-
- internal class ScheduleResponse
- {
- internal readonly ScheduleActionType Action;
- internal readonly Microsoft.Build.BackEnd.BuildRequest BuildRequest;
- internal readonly Microsoft.Build.Execution.BuildResult BuildResult;
- internal readonly int NodeId;
- internal readonly int NumberOfNodesToCreate;
- internal readonly NodeAffinity RequiredNodeType;
- internal readonly BuildRequestUnblocker Unblocker;
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- internal ScheduleResponse(ScheduleActionType type)
- {
- this.Action = type;
- }
-
- private ScheduleResponse(Microsoft.Build.Execution.BuildResult result)
- {
- this.Action = ScheduleActionType.SubmissionComplete;
- this.BuildResult = result;
- }
-
- private ScheduleResponse(NodeAffinity affinity, int count)
- {
- this.Action = ScheduleActionType.CreateNode;
- this.RequiredNodeType = affinity;
- this.NumberOfNodesToCreate = count;
- }
-
- private ScheduleResponse(int node, BuildRequestUnblocker unblocker)
- {
- this.Action = (unblocker.Result == null) ? ScheduleActionType.ResumeExecution : ScheduleActionType.ReportResults;
- this.NodeId = node;
- this.Unblocker = unblocker;
- this.BuildResult = unblocker.Result;
- }
-
- private ScheduleResponse(int nodeId, Microsoft.Build.BackEnd.BuildRequest parentRequest, Microsoft.Build.BackEnd.BuildRequest requestCausingCircularDependency)
- {
- this.Action = ScheduleActionType.CircularDependency;
- this.BuildRequest = requestCausingCircularDependency;
- this.NodeId = nodeId;
- this.Unblocker = new BuildRequestUnblocker(parentRequest, new Microsoft.Build.Execution.BuildResult(requestCausingCircularDependency, true));
- }
-
- private ScheduleResponse(int node, Microsoft.Build.BackEnd.BuildRequest request, bool sendConfiguration)
- {
- this.Action = sendConfiguration ? ScheduleActionType.ScheduleWithConfiguration : ScheduleActionType.Schedule;
- this.NodeId = node;
- this.BuildRequest = request;
- }
-
- public static ScheduleResponse CreateCircularDependencyResponse(int node, Microsoft.Build.BackEnd.BuildRequest parentRequest, Microsoft.Build.BackEnd.BuildRequest requestCausingCircularDependency)
- {
- return new ScheduleResponse(node, parentRequest, requestCausingCircularDependency);
- }
-
- public static ScheduleResponse CreateNewNodeResponse(NodeAffinity typeOfNodeToCreate, int count)
- {
- return new ScheduleResponse(typeOfNodeToCreate, count);
- }
-
- public static ScheduleResponse CreateReportResultResponse(int node, Microsoft.Build.Execution.BuildResult resultToReport)
- {
- return new ScheduleResponse(node, new BuildRequestUnblocker(resultToReport));
- }
-
- public static ScheduleResponse CreateResumeExecutionResponse(int node, int globalRequestIdToResume)
- {
- return new ScheduleResponse(node, new BuildRequestUnblocker(globalRequestIdToResume));
- }
-
- public static ScheduleResponse CreateScheduleResponse(int node, Microsoft.Build.BackEnd.BuildRequest requestToSchedule, bool sendConfiguration)
- {
- return new ScheduleResponse(node, requestToSchedule, sendConfiguration);
- }
-
- public static ScheduleResponse CreateSubmissionCompleteResponse(Microsoft.Build.Execution.BuildResult rootRequestResult)
- {
- return new ScheduleResponse(rootRequestResult);
- }
-
- public override string ToString()
- {
- switch (this.Action)
- {
- case ScheduleActionType.Schedule:
- return string.Format(CultureInfo.CurrentCulture, "Act: {0} Node: {1} Request: {2} Parent {3}", new object[] { this.Action, this.NodeId, this.BuildRequest.GlobalRequestId, this.BuildRequest.ParentGlobalRequestId });
-
- case ScheduleActionType.ScheduleWithConfiguration:
- return string.Format(CultureInfo.CurrentCulture, "Act: {0} Node: {1} Request: {2} Parent {3} Configuration: {4}", new object[] { this.Action, this.NodeId, this.BuildRequest.GlobalRequestId, this.BuildRequest.ParentGlobalRequestId, this.BuildRequest.ConfigurationId });
-
- case ScheduleActionType.ReportResults:
- case ScheduleActionType.ResumeExecution:
- return string.Format(CultureInfo.CurrentCulture, "Act: {0} Node: {1} Request: {2}", new object[] { this.Action, this.NodeId, this.Unblocker.BlockedRequestId });
-
- case ScheduleActionType.CreateNode:
- return string.Format(CultureInfo.CurrentCulture, "Act: {0} Count: {1}", new object[] { this.Action, this.NumberOfNodesToCreate });
-
- case ScheduleActionType.SubmissionComplete:
- return string.Format(CultureInfo.CurrentCulture, "Act: {0} Submission: {1}", new object[] { this.Action, this.BuildResult.SubmissionId });
-
- case ScheduleActionType.CircularDependency:
- return string.Format(CultureInfo.CurrentCulture, "Act: {0} Node: {1} Request: {2} Parent {3} Configuration: {4}", new object[] { this.Action, this.NodeId, this.BuildRequest.GlobalRequestId, this.BuildRequest.ParentGlobalRequestId, this.BuildRequest.ConfigurationId });
- }
- return string.Format(CultureInfo.CurrentCulture, "Act: {0}", new object[] { this.Action });
- }
- }
- }
-