4 // Rolf Bjarne Kvinge (rolf@xamarin.com)
6 // Copyright (C) 2011 Xamarin Inc.
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Generic;
32 namespace Microsoft.Build.Execution
34 public class BuildResult
38 ResultsByTarget = new Dictionary<string, TargetResult> ();
41 public void AddResultsForTarget (string target, TargetResult result)
43 ResultsByTarget.Add (target, result);
46 public bool HasResultsForTarget (string target)
48 return ResultsByTarget.ContainsKey (target);
51 public void MergeResults (BuildResult results)
53 if (ConfigurationId != results.ConfigurationId)
54 throw new InvalidOperationException ("Argument BuildResults have inconsistent ConfigurationId.");
55 if (GlobalRequestId != results.GlobalRequestId)
56 throw new InvalidOperationException ("Argument BuildResults have inconsistent GlobalRequestId.");
57 if (NodeRequestId != results.NodeRequestId)
58 throw new InvalidOperationException ("Argument BuildResults have inconsistent NodeRequestId.");
59 if (ParentGlobalRequestId != results.ParentGlobalRequestId)
60 throw new InvalidOperationException ("Argument BuildResults have inconsistent ParentGlobalRequestId.");
61 if (SubmissionId != results.SubmissionId)
62 throw new InvalidOperationException ("Argument BuildResults have inconsistent SubmissionId.");
64 CircularDependency |= results.CircularDependency;
65 Exception = Exception ?? results.Exception;
66 foreach (var p in results.ResultsByTarget)
67 ResultsByTarget.Add (p.Key, p.Value);
70 public bool CircularDependency { get; internal set; }
72 public int ConfigurationId { get; internal set; }
74 public Exception Exception { get; set; }
76 public int GlobalRequestId { get; internal set; }
78 public ITargetResult this [string target] {
79 get { return ResultsByTarget [target]; }
82 public int NodeRequestId { get; internal set; }
84 BuildResultCode? overall_result;
85 public BuildResultCode OverallResult {
87 if (overall_result == null)
88 throw new InvalidOperationException ("Build has not finished");
89 return overall_result.Value;
91 internal set { overall_result = value; }
94 public int ParentGlobalRequestId { get; internal set; }
96 public IDictionary<string, TargetResult> ResultsByTarget { get; private set; }
98 public int SubmissionId { get; internal set; }