aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs6
-rw-r--r--src/wix/WixToolset.Core/CommandLine/BuildCommand.cs4
-rw-r--r--src/wix/WixToolset.Core/ExtensibilityServices/Messaging.cs6
-rw-r--r--src/wix/WixToolset.Core/Preprocessor.cs11
-rw-r--r--src/wix/test/WixToolsetTest.Converters/Mocks/MockMessaging.cs29
5 files changed, 41 insertions, 15 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs b/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs
index fe77f2a4..15e17e63 100644
--- a/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs
+++ b/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs
@@ -16,6 +16,12 @@ namespace WixToolset.Extensibility.Services
16 bool EncounteredError { get; } 16 bool EncounteredError { get; }
17 17
18 /// <summary> 18 /// <summary>
19 /// Gets the number of errors encountered thus far.
20 /// </summary>
21 /// <value>The number of errors encountered.</value>
22 int ErrorCount { get; }
23
24 /// <summary>
19 /// Gets the last error code encountered during messaging. 25 /// Gets the last error code encountered during messaging.
20 /// </summary> 26 /// </summary>
21 /// <value>The exit code for the process.</value> 27 /// <value>The exit code for the process.</value>
diff --git a/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs b/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
index e63c727c..a00b4b12 100644
--- a/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
+++ b/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
@@ -157,7 +157,7 @@ namespace WixToolset.Core.CommandLine
157 { 157 {
158 var document = this.Preprocess(preprocessorVariables, sourceFile, includeSearchPaths, cancellationToken); 158 var document = this.Preprocess(preprocessorVariables, sourceFile, includeSearchPaths, cancellationToken);
159 159
160 if (this.Messaging.EncounteredError) 160 if (document == null)
161 { 161 {
162 continue; 162 continue;
163 } 163 }
@@ -358,7 +358,7 @@ namespace WixToolset.Core.CommandLine
358 { 358 {
359 var document = this.Preprocess(preprocessorVariables, loc, includeSearchPaths, cancellationToken); 359 var document = this.Preprocess(preprocessorVariables, loc, includeSearchPaths, cancellationToken);
360 360
361 if (this.Messaging.EncounteredError) 361 if (document == null)
362 { 362 {
363 continue; 363 continue;
364 } 364 }
diff --git a/src/wix/WixToolset.Core/ExtensibilityServices/Messaging.cs b/src/wix/WixToolset.Core/ExtensibilityServices/Messaging.cs
index 280d845c..9a7413f4 100644
--- a/src/wix/WixToolset.Core/ExtensibilityServices/Messaging.cs
+++ b/src/wix/WixToolset.Core/ExtensibilityServices/Messaging.cs
@@ -13,7 +13,9 @@ namespace WixToolset.Core.ExtensibilityServices
13 private readonly HashSet<int> suppressedWarnings = new HashSet<int>(); 13 private readonly HashSet<int> suppressedWarnings = new HashSet<int>();
14 private readonly HashSet<int> warningsAsErrors = new HashSet<int>(); 14 private readonly HashSet<int> warningsAsErrors = new HashSet<int>();
15 15
16 public bool EncounteredError { get; private set; } 16 public bool EncounteredError => this.ErrorCount > 0;
17
18 public int ErrorCount { get; private set; }
17 19
18 public int LastErrorNumber { get; private set; } 20 public int LastErrorNumber { get; private set; }
19 21
@@ -49,7 +51,7 @@ namespace WixToolset.Core.ExtensibilityServices
49 51
50 if (level == MessageLevel.Error) 52 if (level == MessageLevel.Error)
51 { 53 {
52 this.EncounteredError = true; 54 ++this.ErrorCount;
53 this.LastErrorNumber = message.Id; 55 this.LastErrorNumber = message.Id;
54 } 56 }
55 57
diff --git a/src/wix/WixToolset.Core/Preprocessor.cs b/src/wix/WixToolset.Core/Preprocessor.cs
index 084da8d0..a71e5bb7 100644
--- a/src/wix/WixToolset.Core/Preprocessor.cs
+++ b/src/wix/WixToolset.Core/Preprocessor.cs
@@ -141,6 +141,8 @@ namespace WixToolset.Core
141 { 141 {
142 state.CurrentFileStack.Push(state.Helper.GetVariableValue(state.Context, "sys", "SOURCEFILEDIR")); 142 state.CurrentFileStack.Push(state.Helper.GetVariableValue(state.Context, "sys", "SOURCEFILEDIR"));
143 143
144 var beforeErrorCount = this.Messaging.ErrorCount;
145
144 // Process the reader into the output. 146 // Process the reader into the output.
145 IPreprocessResult result = null; 147 IPreprocessResult result = null;
146 try 148 try
@@ -150,7 +152,7 @@ namespace WixToolset.Core
150 // Fire event with post-processed document. 152 // Fire event with post-processed document.
151 this.ProcessedStream?.Invoke(this, new ProcessedStreamEventArgs(state.Context.SourcePath, state.Output)); 153 this.ProcessedStream?.Invoke(this, new ProcessedStreamEventArgs(state.Context.SourcePath, state.Output));
152 154
153 if (!this.Messaging.EncounteredError) 155 if (beforeErrorCount == this.Messaging.ErrorCount)
154 { 156 {
155 result = this.ServiceProvider.GetService<IPreprocessResult>(); 157 result = this.ServiceProvider.GetService<IPreprocessResult>();
156 result.Document = state.Output; 158 result.Document = state.Output;
@@ -292,7 +294,7 @@ namespace WixToolset.Core
292 if (XmlNodeType.ProcessingInstruction == reader.NodeType) 294 if (XmlNodeType.ProcessingInstruction == reader.NodeType)
293 { 295 {
294 var ignore = false; 296 var ignore = false;
295 string name = null; 297 string name;
296 298
297 switch (reader.LocalName) 299 switch (reader.LocalName)
298 { 300 {
@@ -423,7 +425,6 @@ namespace WixToolset.Core
423 break; 425 break;
424 } 426 }
425 } 427 }
426
427 } 428 }
428 //else 429 //else
429 //{ 430 //{
@@ -826,7 +827,7 @@ namespace WixToolset.Core
826 private string GetNextToken(ProcessingState state, string originalExpression, ref string expression, out bool stringLiteral) 827 private string GetNextToken(ProcessingState state, string originalExpression, ref string expression, out bool stringLiteral)
827 { 828 {
828 stringLiteral = false; 829 stringLiteral = false;
829 var token = String.Empty; 830 string token;
830 expression = expression.Trim(); 831 expression = expression.Trim();
831 if (0 == expression.Length) 832 if (0 == expression.Length)
832 { 833 {
@@ -1280,7 +1281,7 @@ namespace WixToolset.Core
1280 /// <returns>Boolean to indicate if the expression is true or false</returns> 1281 /// <returns>Boolean to indicate if the expression is true or false</returns>
1281 private bool EvaluateExpressionRecurse(ProcessingState state, string originalExpression, ref string expression, PreprocessorOperation prevResultOperation, bool prevResult) 1282 private bool EvaluateExpressionRecurse(ProcessingState state, string originalExpression, ref string expression, PreprocessorOperation prevResultOperation, bool prevResult)
1282 { 1283 {
1283 var expressionValue = false; 1284 bool expressionValue;
1284 expression = expression.Trim(); 1285 expression = expression.Trim();
1285 if (expression.Length == 0) 1286 if (expression.Length == 0)
1286 { 1287 {
diff --git a/src/wix/test/WixToolsetTest.Converters/Mocks/MockMessaging.cs b/src/wix/test/WixToolsetTest.Converters/Mocks/MockMessaging.cs
index 77821a1c..2bc10772 100644
--- a/src/wix/test/WixToolsetTest.Converters/Mocks/MockMessaging.cs
+++ b/src/wix/test/WixToolsetTest.Converters/Mocks/MockMessaging.cs
@@ -12,7 +12,9 @@ namespace WixToolsetTest.Converters.Mocks
12 { 12 {
13 public List<Message> Messages { get; } = new List<Message>(); 13 public List<Message> Messages { get; } = new List<Message>();
14 14
15 public bool EncounteredError { get; private set; } 15 public bool EncounteredError => this.ErrorCount > 0;
16
17 public int ErrorCount { get; private set; }
16 18
17 public int LastErrorNumber { get; } 19 public int LastErrorNumber { get; }
18 20
@@ -22,18 +24,33 @@ namespace WixToolsetTest.Converters.Mocks
22 24
23 public bool WarningsAsError { get; set; } 25 public bool WarningsAsError { get; set; }
24 26
25 public void ElevateWarningMessage(int warningNumber) => throw new NotImplementedException(); 27 public void ElevateWarningMessage(int warningNumber)
28 {
29 throw new NotImplementedException();
30 }
26 31
27 public void SetListener(IMessageListener listener) => throw new NotImplementedException(); 32 public void SetListener(IMessageListener listener)
33 {
34 throw new NotImplementedException();
35 }
28 36
29 public void SuppressWarningMessage(int warningNumber) => throw new NotImplementedException(); 37 public void SuppressWarningMessage(int warningNumber)
38 {
39 throw new NotImplementedException();
40 }
30 41
31 public void Write(Message message) 42 public void Write(Message message)
32 { 43 {
33 this.Messages.Add(message); 44 this.Messages.Add(message);
34 this.EncounteredError |= message.Level == MessageLevel.Error; 45 if (message.Level == MessageLevel.Error)
46 {
47 ++this.ErrorCount;
48 }
35 } 49 }
36 50
37 public void Write(string message, bool verbose = false) => throw new NotImplementedException(); 51 public void Write(string message, bool verbose = false)
52 {
53 throw new NotImplementedException();
54 }
38 } 55 }
39} 56}