PageRenderTime 60ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. namespace Microsoft.Build.BackEnd
  2. {
  3. using Microsoft.Build.Execution;
  4. using System;
  5. using System.Globalization;
  6. using System.Runtime;
  7. internal class ScheduleResponse
  8. {
  9. internal readonly ScheduleActionType Action;
  10. internal readonly Microsoft.Build.BackEnd.BuildRequest BuildRequest;
  11. internal readonly Microsoft.Build.Execution.BuildResult BuildResult;
  12. internal readonly int NodeId;
  13. internal readonly int NumberOfNodesToCreate;
  14. internal readonly NodeAffinity RequiredNodeType;
  15. internal readonly BuildRequestUnblocker Unblocker;
  16. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  17. internal ScheduleResponse(ScheduleActionType type)
  18. {
  19. this.Action = type;
  20. }
  21. private ScheduleResponse(Microsoft.Build.Execution.BuildResult result)
  22. {
  23. this.Action = ScheduleActionType.SubmissionComplete;
  24. this.BuildResult = result;
  25. }
  26. private ScheduleResponse(NodeAffinity affinity, int count)
  27. {
  28. this.Action = ScheduleActionType.CreateNode;
  29. this.RequiredNodeType = affinity;
  30. this.NumberOfNodesToCreate = count;
  31. }
  32. private ScheduleResponse(int node, BuildRequestUnblocker unblocker)
  33. {
  34. this.Action = (unblocker.Result == null) ? ScheduleActionType.ResumeExecution : ScheduleActionType.ReportResults;
  35. this.NodeId = node;
  36. this.Unblocker = unblocker;
  37. this.BuildResult = unblocker.Result;
  38. }
  39. private ScheduleResponse(int nodeId, Microsoft.Build.BackEnd.BuildRequest parentRequest, Microsoft.Build.BackEnd.BuildRequest requestCausingCircularDependency)
  40. {
  41. this.Action = ScheduleActionType.CircularDependency;
  42. this.BuildRequest = requestCausingCircularDependency;
  43. this.NodeId = nodeId;
  44. this.Unblocker = new BuildRequestUnblocker(parentRequest, new Microsoft.Build.Execution.BuildResult(requestCausingCircularDependency, true));
  45. }
  46. private ScheduleResponse(int node, Microsoft.Build.BackEnd.BuildRequest request, bool sendConfiguration)
  47. {
  48. this.Action = sendConfiguration ? ScheduleActionType.ScheduleWithConfiguration : ScheduleActionType.Schedule;
  49. this.NodeId = node;
  50. this.BuildRequest = request;
  51. }
  52. public static ScheduleResponse CreateCircularDependencyResponse(int node, Microsoft.Build.BackEnd.BuildRequest parentRequest, Microsoft.Build.BackEnd.BuildRequest requestCausingCircularDependency)
  53. {
  54. return new ScheduleResponse(node, parentRequest, requestCausingCircularDependency);
  55. }
  56. public static ScheduleResponse CreateNewNodeResponse(NodeAffinity typeOfNodeToCreate, int count)
  57. {
  58. return new ScheduleResponse(typeOfNodeToCreate, count);
  59. }
  60. public static ScheduleResponse CreateReportResultResponse(int node, Microsoft.Build.Execution.BuildResult resultToReport)
  61. {
  62. return new ScheduleResponse(node, new BuildRequestUnblocker(resultToReport));
  63. }
  64. public static ScheduleResponse CreateResumeExecutionResponse(int node, int globalRequestIdToResume)
  65. {
  66. return new ScheduleResponse(node, new BuildRequestUnblocker(globalRequestIdToResume));
  67. }
  68. public static ScheduleResponse CreateScheduleResponse(int node, Microsoft.Build.BackEnd.BuildRequest requestToSchedule, bool sendConfiguration)
  69. {
  70. return new ScheduleResponse(node, requestToSchedule, sendConfiguration);
  71. }
  72. public static ScheduleResponse CreateSubmissionCompleteResponse(Microsoft.Build.Execution.BuildResult rootRequestResult)
  73. {
  74. return new ScheduleResponse(rootRequestResult);
  75. }
  76. public override string ToString()
  77. {
  78. switch (this.Action)
  79. {
  80. case ScheduleActionType.Schedule:
  81. 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 });
  82. case ScheduleActionType.ScheduleWithConfiguration:
  83. 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 });
  84. case ScheduleActionType.ReportResults:
  85. case ScheduleActionType.ResumeExecution:
  86. return string.Format(CultureInfo.CurrentCulture, "Act: {0} Node: {1} Request: {2}", new object[] { this.Action, this.NodeId, this.Unblocker.BlockedRequestId });
  87. case ScheduleActionType.CreateNode:
  88. return string.Format(CultureInfo.CurrentCulture, "Act: {0} Count: {1}", new object[] { this.Action, this.NumberOfNodesToCreate });
  89. case ScheduleActionType.SubmissionComplete:
  90. return string.Format(CultureInfo.CurrentCulture, "Act: {0} Submission: {1}", new object[] { this.Action, this.BuildResult.SubmissionId });
  91. case ScheduleActionType.CircularDependency:
  92. 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 });
  93. }
  94. return string.Format(CultureInfo.CurrentCulture, "Act: {0}", new object[] { this.Action });
  95. }
  96. }
  97. }