PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Microsoft.Build/Microsoft.Build/Microsoft/Build/BackEnd/BuildRequest.cs

#
C# | 213 lines | 192 code | 21 blank | 0 comment | 8 complexity | 4d705f06ea46598ecef08bc63e974807 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 Microsoft.Build.Framework;
  5. using Microsoft.Build.Shared;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Runtime;
  10. internal class BuildRequest : INodePacket, INodePacketTranslatable
  11. {
  12. private Microsoft.Build.Framework.BuildEventContext buildEventContext;
  13. private int configurationId;
  14. private int globalRequestId;
  15. private Microsoft.Build.Execution.HostServices hostServices;
  16. public const int InvalidGlobalRequestId = -1;
  17. private int nodeRequestId;
  18. private Microsoft.Build.Framework.BuildEventContext parentBuildEventContext;
  19. private int parentGlobalRequestId;
  20. private int submissionId;
  21. private List<string> targets;
  22. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  23. public BuildRequest()
  24. {
  25. }
  26. private BuildRequest(INodePacketTranslator translator)
  27. {
  28. this.Translate(translator);
  29. }
  30. public BuildRequest(int submissionId, int nodeRequestId, int configurationId, ICollection<string> escapedTargets, Microsoft.Build.Execution.HostServices hostServices, Microsoft.Build.Framework.BuildEventContext parentBuildEventContext, BuildRequest parentRequest)
  31. {
  32. ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets");
  33. ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, "parentBuildEventContext");
  34. this.submissionId = submissionId;
  35. this.configurationId = configurationId;
  36. this.targets = new List<string>(escapedTargets.Count);
  37. foreach (string str in escapedTargets)
  38. {
  39. this.targets.Add(EscapingUtilities.UnescapeAll(str));
  40. }
  41. this.hostServices = hostServices;
  42. this.buildEventContext = Microsoft.Build.Framework.BuildEventContext.Invalid;
  43. this.parentBuildEventContext = parentBuildEventContext;
  44. this.globalRequestId = -1;
  45. if (parentRequest != null)
  46. {
  47. this.parentGlobalRequestId = parentRequest.GlobalRequestId;
  48. }
  49. else
  50. {
  51. this.parentGlobalRequestId = -1;
  52. }
  53. this.nodeRequestId = nodeRequestId;
  54. }
  55. internal bool DoesResultApplyToRequest(BuildResult result)
  56. {
  57. return ((this.globalRequestId == result.GlobalRequestId) && (this.nodeRequestId == result.NodeRequestId));
  58. }
  59. internal static INodePacket FactoryForDeserialization(INodePacketTranslator translator)
  60. {
  61. return new BuildRequest(translator);
  62. }
  63. public void ResolveConfiguration(int newConfigId)
  64. {
  65. ErrorUtilities.VerifyThrow(!this.IsConfigurationResolved, "Configuration already resolved");
  66. this.configurationId = newConfigId;
  67. ErrorUtilities.VerifyThrow(this.IsConfigurationResolved, "Configuration not resolved");
  68. }
  69. public void Translate(INodePacketTranslator translator)
  70. {
  71. translator.Translate(ref this.submissionId);
  72. translator.Translate(ref this.configurationId);
  73. translator.Translate(ref this.globalRequestId);
  74. translator.Translate(ref this.parentGlobalRequestId);
  75. translator.Translate(ref this.nodeRequestId);
  76. translator.Translate(ref this.targets);
  77. translator.Translate(ref this.parentBuildEventContext);
  78. translator.Translate(ref this.buildEventContext);
  79. }
  80. public Microsoft.Build.Framework.BuildEventContext BuildEventContext
  81. {
  82. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  83. get
  84. {
  85. return this.buildEventContext;
  86. }
  87. set
  88. {
  89. ErrorUtilities.VerifyThrow(this.buildEventContext == Microsoft.Build.Framework.BuildEventContext.Invalid, "The build event context is already set.");
  90. this.buildEventContext = value;
  91. }
  92. }
  93. public int ConfigurationId
  94. {
  95. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  96. get
  97. {
  98. return this.configurationId;
  99. }
  100. }
  101. public int GlobalRequestId
  102. {
  103. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  104. get
  105. {
  106. return this.globalRequestId;
  107. }
  108. set
  109. {
  110. ErrorUtilities.VerifyThrow(this.globalRequestId == -1, "Global Request ID cannot be set twice.");
  111. this.globalRequestId = value;
  112. }
  113. }
  114. internal Microsoft.Build.Execution.HostServices HostServices
  115. {
  116. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  117. get
  118. {
  119. return this.hostServices;
  120. }
  121. }
  122. public bool IsConfigurationResolved
  123. {
  124. [DebuggerStepThrough]
  125. get
  126. {
  127. return (this.configurationId > 0);
  128. }
  129. }
  130. internal bool IsRootRequest
  131. {
  132. [DebuggerStepThrough]
  133. get
  134. {
  135. return (this.parentGlobalRequestId == -1);
  136. }
  137. }
  138. public int NodeRequestId
  139. {
  140. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  141. get
  142. {
  143. return this.nodeRequestId;
  144. }
  145. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  146. set
  147. {
  148. this.nodeRequestId = value;
  149. }
  150. }
  151. public Microsoft.Build.Framework.BuildEventContext ParentBuildEventContext
  152. {
  153. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  154. get
  155. {
  156. return this.parentBuildEventContext;
  157. }
  158. }
  159. public int ParentGlobalRequestId
  160. {
  161. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  162. get
  163. {
  164. return this.parentGlobalRequestId;
  165. }
  166. }
  167. public int SubmissionId
  168. {
  169. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  170. get
  171. {
  172. return this.submissionId;
  173. }
  174. }
  175. public List<string> Targets
  176. {
  177. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  178. get
  179. {
  180. return this.targets;
  181. }
  182. }
  183. public NodePacketType Type
  184. {
  185. [DebuggerStepThrough]
  186. get
  187. {
  188. return NodePacketType.BuildRequest;
  189. }
  190. }
  191. }
  192. }