aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Preprocessor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Preprocessor.cs')
-rw-r--r--src/WixToolset.Core/Preprocessor.cs72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/WixToolset.Core/Preprocessor.cs b/src/WixToolset.Core/Preprocessor.cs
index 195ede9e..53d60c87 100644
--- a/src/WixToolset.Core/Preprocessor.cs
+++ b/src/WixToolset.Core/Preprocessor.cs
@@ -136,7 +136,7 @@ namespace WixToolset.Core
136 } 136 }
137 else 137 else
138 { 138 {
139 this.Context.Messaging.OnMessage(WixErrors.DuplicateExtensionPreprocessorType(extension.GetType().ToString(), prefix, collidingExtension.GetType().ToString())); 139 this.Context.Messaging.Write(ErrorMessages.DuplicateExtensionPreprocessorType(extension.GetType().ToString(), prefix, collidingExtension.GetType().ToString()));
140 } 140 }
141 } 141 }
142 } 142 }
@@ -159,7 +159,7 @@ namespace WixToolset.Core
159 catch (XmlException e) 159 catch (XmlException e)
160 { 160 {
161 this.UpdateCurrentLineNumber(reader, 0); 161 this.UpdateCurrentLineNumber(reader, 0);
162 throw new WixException(WixErrors.InvalidXml(this.Context.CurrentSourceLineNumber, "source", e.Message)); 162 throw new WixException(ErrorMessages.InvalidXml(this.Context.CurrentSourceLineNumber, "source", e.Message));
163 } 163 }
164 finally 164 finally
165 { 165 {
@@ -347,12 +347,12 @@ namespace WixToolset.Core
347 case "elseif": 347 case "elseif":
348 if (0 == ifStack.Count) 348 if (0 == ifStack.Count)
349 { 349 {
350 throw new WixException(WixErrors.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "elseif")); 350 throw new WixException(ErrorMessages.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "elseif"));
351 } 351 }
352 352
353 if (IfState.If != ifContext.IfState && IfState.ElseIf != ifContext.IfState) 353 if (IfState.If != ifContext.IfState && IfState.ElseIf != ifContext.IfState)
354 { 354 {
355 throw new WixException(WixErrors.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "elseif")); 355 throw new WixException(ErrorMessages.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "elseif"));
356 } 356 }
357 357
358 ifContext.IfState = IfState.ElseIf; // we're now in an elseif 358 ifContext.IfState = IfState.ElseIf; // we're now in an elseif
@@ -370,12 +370,12 @@ namespace WixToolset.Core
370 case "else": 370 case "else":
371 if (0 == ifStack.Count) 371 if (0 == ifStack.Count)
372 { 372 {
373 throw new WixException(WixErrors.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "else")); 373 throw new WixException(ErrorMessages.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "else"));
374 } 374 }
375 375
376 if (IfState.If != ifContext.IfState && IfState.ElseIf != ifContext.IfState) 376 if (IfState.If != ifContext.IfState && IfState.ElseIf != ifContext.IfState)
377 { 377 {
378 throw new WixException(WixErrors.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "else")); 378 throw new WixException(ErrorMessages.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "else"));
379 } 379 }
380 380
381 ifContext.IfState = IfState.Else; // we're now in an else 381 ifContext.IfState = IfState.Else; // we're now in an else
@@ -386,7 +386,7 @@ namespace WixToolset.Core
386 case "endif": 386 case "endif":
387 if (0 == ifStack.Count) 387 if (0 == ifStack.Count)
388 { 388 {
389 throw new WixException(WixErrors.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "endif")); 389 throw new WixException(ErrorMessages.UnmatchedPreprocessorInstruction(sourceLineNumbers, "if", "endif"));
390 } 390 }
391 391
392 ifContext = (IfContext)ifStack.Pop(); 392 ifContext = (IfContext)ifStack.Pop();
@@ -466,7 +466,7 @@ namespace WixToolset.Core
466 break; 466 break;
467 467
468 case "endforeach": // endforeach is handled in PreprocessForeach, so seeing it here is an error 468 case "endforeach": // endforeach is handled in PreprocessForeach, so seeing it here is an error
469 throw new WixException(WixErrors.UnmatchedPreprocessorInstruction(sourceLineNumbers, "foreach", "endforeach")); 469 throw new WixException(ErrorMessages.UnmatchedPreprocessorInstruction(sourceLineNumbers, "foreach", "endforeach"));
470 470
471 case "pragma": 471 case "pragma":
472 this.PreprocessPragma(reader.Value, currentContainer); 472 this.PreprocessPragma(reader.Value, currentContainer);
@@ -483,7 +483,7 @@ namespace WixToolset.Core
483 { 483 {
484 if ("Include" != reader.LocalName) 484 if ("Include" != reader.LocalName)
485 { 485 {
486 this.Context.Messaging.OnMessage(WixErrors.InvalidDocumentElement(sourceLineNumbers, reader.Name, "include", "Include")); 486 this.Context.Messaging.Write(ErrorMessages.InvalidDocumentElement(sourceLineNumbers, reader.Name, "include", "Include"));
487 } 487 }
488 488
489 this.IncludeNextStack.Pop(); 489 this.IncludeNextStack.Pop();
@@ -540,13 +540,13 @@ namespace WixToolset.Core
540 540
541 if (0 != ifStack.Count) 541 if (0 != ifStack.Count)
542 { 542 {
543 throw new WixException(WixErrors.NonterminatedPreprocessorInstruction(this.Context.CurrentSourceLineNumber, "if", "endif")); 543 throw new WixException(ErrorMessages.NonterminatedPreprocessorInstruction(this.Context.CurrentSourceLineNumber, "if", "endif"));
544 } 544 }
545 545
546 // TODO: can this actually happen? 546 // TODO: can this actually happen?
547 if (0 != containerStack.Count) 547 if (0 != containerStack.Count)
548 { 548 {
549 throw new WixException(WixErrors.NonterminatedPreprocessorInstruction(this.Context.CurrentSourceLineNumber, "nodes", "nodes")); 549 throw new WixException(ErrorMessages.NonterminatedPreprocessorInstruction(this.Context.CurrentSourceLineNumber, "nodes", "nodes"));
550 } 550 }
551 } 551 }
552 552
@@ -559,7 +559,7 @@ namespace WixToolset.Core
559 // Resolve other variables in the error message. 559 // Resolve other variables in the error message.
560 errorMessage = this.Helper.PreprocessString(this.Context, errorMessage); 560 errorMessage = this.Helper.PreprocessString(this.Context, errorMessage);
561 561
562 throw new WixException(WixErrors.PreprocessorError(this.Context.CurrentSourceLineNumber, errorMessage)); 562 throw new WixException(ErrorMessages.PreprocessorError(this.Context.CurrentSourceLineNumber, errorMessage));
563 } 563 }
564 564
565 /// <summary> 565 /// <summary>
@@ -571,7 +571,7 @@ namespace WixToolset.Core
571 // Resolve other variables in the warning message. 571 // Resolve other variables in the warning message.
572 warningMessage = this.Helper.PreprocessString(this.Context, warningMessage); 572 warningMessage = this.Helper.PreprocessString(this.Context, warningMessage);
573 573
574 this.Context.Messaging.OnMessage(WixWarnings.PreprocessorWarning(this.Context.CurrentSourceLineNumber, warningMessage)); 574 this.Context.Messaging.Write(WarningMessages.PreprocessorWarning(this.Context.CurrentSourceLineNumber, warningMessage));
575 } 575 }
576 576
577 /// <summary> 577 /// <summary>
@@ -584,7 +584,7 @@ namespace WixToolset.Core
584 584
585 if (!match.Success) 585 if (!match.Success)
586 { 586 {
587 throw new WixException(WixErrors.IllegalDefineStatement(this.Context.CurrentSourceLineNumber, originalDefine)); 587 throw new WixException(ErrorMessages.IllegalDefineStatement(this.Context.CurrentSourceLineNumber, originalDefine));
588 } 588 }
589 589
590 var defineName = match.Groups["varName"].Value; 590 var defineName = match.Groups["varName"].Value;
@@ -645,7 +645,7 @@ namespace WixToolset.Core
645 645
646 if (null == includeFile) 646 if (null == includeFile)
647 { 647 {
648 throw new WixException(WixErrors.FileNotFound(sourceLineNumbers, includePath, "include")); 648 throw new WixException(ErrorMessages.FileNotFound(sourceLineNumbers, includePath, "include"));
649 } 649 }
650 650
651 using (XmlReader reader = XmlReader.Create(includeFile, DocumentXmlReaderSettings)) 651 using (XmlReader reader = XmlReader.Create(includeFile, DocumentXmlReaderSettings))
@@ -660,7 +660,7 @@ namespace WixToolset.Core
660 catch (XmlException e) 660 catch (XmlException e)
661 { 661 {
662 this.UpdateCurrentLineNumber(reader, 0); 662 this.UpdateCurrentLineNumber(reader, 0);
663 throw new WixException(WixErrors.InvalidXml(sourceLineNumbers, "source", e.Message)); 663 throw new WixException(ErrorMessages.InvalidXml(sourceLineNumbers, "source", e.Message));
664 } 664 }
665 665
666 this.IncludedFile?.Invoke(this, new IncludedFileEventArgs(sourceLineNumbers, includeFile)); 666 this.IncludedFile?.Invoke(this, new IncludedFileEventArgs(sourceLineNumbers, includeFile));
@@ -681,7 +681,7 @@ namespace WixToolset.Core
681 var indexOfInToken = reader.Value.IndexOf(" in ", StringComparison.Ordinal); 681 var indexOfInToken = reader.Value.IndexOf(" in ", StringComparison.Ordinal);
682 if (0 > indexOfInToken) 682 if (0 > indexOfInToken)
683 { 683 {
684 throw new WixException(WixErrors.IllegalForeach(this.Context.CurrentSourceLineNumber, reader.Value)); 684 throw new WixException(ErrorMessages.IllegalForeach(this.Context.CurrentSourceLineNumber, reader.Value));
685 } 685 }
686 686
687 // parse out the variable name 687 // parse out the variable name
@@ -751,7 +751,7 @@ namespace WixToolset.Core
751 } 751 }
752 else if (reader.NodeType == XmlNodeType.None) 752 else if (reader.NodeType == XmlNodeType.None)
753 { 753 {
754 throw new WixException(WixErrors.ExpectedEndforeach(this.Context.CurrentSourceLineNumber)); 754 throw new WixException(ErrorMessages.ExpectedEndforeach(this.Context.CurrentSourceLineNumber));
755 } 755 }
756 756
757 reader.Read(); 757 reader.Read();
@@ -773,7 +773,7 @@ namespace WixToolset.Core
773 catch (XmlException e) 773 catch (XmlException e)
774 { 774 {
775 this.UpdateCurrentLineNumber(loopReader, offset); 775 this.UpdateCurrentLineNumber(loopReader, offset);
776 throw new WixException(WixErrors.InvalidXml(this.Context.CurrentSourceLineNumber, "source", e.Message)); 776 throw new WixException(ErrorMessages.InvalidXml(this.Context.CurrentSourceLineNumber, "source", e.Message));
777 } 777 }
778 778
779 fragmentStream.Position = 0; // seek back to the beginning for the next loop. 779 fragmentStream.Position = 0; // seek back to the beginning for the next loop.
@@ -791,7 +791,7 @@ namespace WixToolset.Core
791 791
792 if (!match.Success) 792 if (!match.Success)
793 { 793 {
794 throw new WixException(WixErrors.InvalidPreprocessorPragma(this.Context.CurrentSourceLineNumber, pragmaText)); 794 throw new WixException(ErrorMessages.InvalidPreprocessorPragma(this.Context.CurrentSourceLineNumber, pragmaText));
795 } 795 }
796 796
797 // resolve other variables in the pragma argument(s) 797 // resolve other variables in the pragma argument(s)
@@ -803,7 +803,7 @@ namespace WixToolset.Core
803 } 803 }
804 catch (Exception e) 804 catch (Exception e)
805 { 805 {
806 throw new WixException(WixErrors.PreprocessorExtensionPragmaFailed(this.Context.CurrentSourceLineNumber, pragmaText, e.Message)); 806 throw new WixException(ErrorMessages.PreprocessorExtensionPragmaFailed(this.Context.CurrentSourceLineNumber, pragmaText, e.Message));
807 } 807 }
808 } 808 }
809 809
@@ -830,7 +830,7 @@ namespace WixToolset.Core
830 int endingQuotes = expression.IndexOf('\"', 1); 830 int endingQuotes = expression.IndexOf('\"', 1);
831 if (-1 == endingQuotes) 831 if (-1 == endingQuotes)
832 { 832 {
833 throw new WixException(WixErrors.UnmatchedQuotesInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 833 throw new WixException(ErrorMessages.UnmatchedQuotesInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
834 } 834 }
835 835
836 // cut the quotes off the string 836 // cut the quotes off the string
@@ -864,7 +864,7 @@ namespace WixToolset.Core
864 864
865 if (-1 == endingParen) 865 if (-1 == endingParen)
866 { 866 {
867 throw new WixException(WixErrors.UnmatchedParenthesisInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 867 throw new WixException(ErrorMessages.UnmatchedParenthesisInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
868 } 868 }
869 token = expression.Substring(0, endingParen + 1); 869 token = expression.Substring(0, endingParen + 1);
870 870
@@ -981,12 +981,12 @@ namespace WixToolset.Core
981 else if (variable.IndexOf("(", StringComparison.Ordinal) != -1 || variable.IndexOf(")", StringComparison.Ordinal) != -1) 981 else if (variable.IndexOf("(", StringComparison.Ordinal) != -1 || variable.IndexOf(")", StringComparison.Ordinal) != -1)
982 { 982 {
983 // make sure it doesn't contain parenthesis 983 // make sure it doesn't contain parenthesis
984 throw new WixException(WixErrors.UnmatchedParenthesisInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 984 throw new WixException(ErrorMessages.UnmatchedParenthesisInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
985 } 985 }
986 else if (variable.IndexOf("\"", StringComparison.Ordinal) != -1) 986 else if (variable.IndexOf("\"", StringComparison.Ordinal) != -1)
987 { 987 {
988 // shouldn't contain quotes 988 // shouldn't contain quotes
989 throw new WixException(WixErrors.UnmatchedQuotesInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 989 throw new WixException(ErrorMessages.UnmatchedQuotesInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
990 } 990 }
991 991
992 return varValue; 992 return varValue;
@@ -1017,7 +1017,7 @@ namespace WixToolset.Core
1017 { 1017 {
1018 if (stringLiteral) 1018 if (stringLiteral)
1019 { 1019 {
1020 throw new WixException(WixErrors.UnmatchedQuotesInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 1020 throw new WixException(ErrorMessages.UnmatchedQuotesInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
1021 } 1021 }
1022 1022
1023 rightValue = this.GetNextToken(originalExpression, ref expression, out stringLiteral); 1023 rightValue = this.GetNextToken(originalExpression, ref expression, out stringLiteral);
@@ -1068,7 +1068,7 @@ namespace WixToolset.Core
1068 { 1068 {
1069 if (operation.Length > 0) 1069 if (operation.Length > 0)
1070 { 1070 {
1071 throw new WixException(WixErrors.ExpectedVariable(this.Context.CurrentSourceLineNumber, originalExpression)); 1071 throw new WixException(ErrorMessages.ExpectedVariable(this.Context.CurrentSourceLineNumber, originalExpression));
1072 } 1072 }
1073 1073
1074 // false expression 1074 // false expression
@@ -1083,7 +1083,7 @@ namespace WixToolset.Core
1083 } 1083 }
1084 else 1084 else
1085 { 1085 {
1086 throw new WixException(WixErrors.UnexpectedLiteral(this.Context.CurrentSourceLineNumber, originalExpression)); 1086 throw new WixException(ErrorMessages.UnexpectedLiteral(this.Context.CurrentSourceLineNumber, originalExpression));
1087 } 1087 }
1088 } 1088 }
1089 else 1089 else
@@ -1123,11 +1123,11 @@ namespace WixToolset.Core
1123 } 1123 }
1124 catch (FormatException) 1124 catch (FormatException)
1125 { 1125 {
1126 throw new WixException(WixErrors.IllegalIntegerInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 1126 throw new WixException(ErrorMessages.IllegalIntegerInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
1127 } 1127 }
1128 catch (OverflowException) 1128 catch (OverflowException)
1129 { 1129 {
1130 throw new WixException(WixErrors.IllegalIntegerInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 1130 throw new WixException(ErrorMessages.IllegalIntegerInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
1131 } 1131 }
1132 1132
1133 // Compare the numbers 1133 // Compare the numbers
@@ -1169,7 +1169,7 @@ namespace WixToolset.Core
1169 closeParenIndex = expression.IndexOf(')', closeParenIndex); 1169 closeParenIndex = expression.IndexOf(')', closeParenIndex);
1170 if (closeParenIndex == -1) 1170 if (closeParenIndex == -1)
1171 { 1171 {
1172 throw new WixException(WixErrors.UnmatchedParenthesisInExpression(this.Context.CurrentSourceLineNumber, originalExpression)); 1172 throw new WixException(ErrorMessages.UnmatchedParenthesisInExpression(this.Context.CurrentSourceLineNumber, originalExpression));
1173 } 1173 }
1174 1174
1175 if (InsideQuotes(expression, closeParenIndex)) 1175 if (InsideQuotes(expression, closeParenIndex))
@@ -1218,7 +1218,7 @@ namespace WixToolset.Core
1218 currentValue = !currentValue; 1218 currentValue = !currentValue;
1219 break; 1219 break;
1220 default: 1220 default:
1221 throw new WixException(WixErrors.UnexpectedPreprocessorOperator(this.Context.CurrentSourceLineNumber, operation.ToString())); 1221 throw new WixException(ErrorMessages.UnexpectedPreprocessorOperator(this.Context.CurrentSourceLineNumber, operation.ToString()));
1222 } 1222 }
1223 } 1223 }
1224 1224
@@ -1267,7 +1267,7 @@ namespace WixToolset.Core
1267 expression = expression.Trim(); 1267 expression = expression.Trim();
1268 if (expression.Length == 0) 1268 if (expression.Length == 0)
1269 { 1269 {
1270 throw new WixException(WixErrors.UnexpectedEmptySubexpression(this.Context.CurrentSourceLineNumber, originalExpression)); 1270 throw new WixException(ErrorMessages.UnexpectedEmptySubexpression(this.Context.CurrentSourceLineNumber, originalExpression));
1271 } 1271 }
1272 1272
1273 // If the expression starts with parenthesis, evaluate it 1273 // If the expression starts with parenthesis, evaluate it
@@ -1288,7 +1288,7 @@ namespace WixToolset.Core
1288 expression = expression.Substring(3).Trim(); 1288 expression = expression.Substring(3).Trim();
1289 if (expression.Length == 0) 1289 if (expression.Length == 0)
1290 { 1290 {
1291 throw new WixException(WixErrors.ExpectedExpressionAfterNot(this.Context.CurrentSourceLineNumber, originalExpression)); 1291 throw new WixException(ErrorMessages.ExpectedExpressionAfterNot(this.Context.CurrentSourceLineNumber, originalExpression));
1292 } 1292 }
1293 1293
1294 expressionValue = this.EvaluateExpressionRecurse(originalExpression, ref expression, PreprocessorOperation.Not, true); 1294 expressionValue = this.EvaluateExpressionRecurse(originalExpression, ref expression, PreprocessorOperation.Not, true);
@@ -1317,7 +1317,7 @@ namespace WixToolset.Core
1317 } 1317 }
1318 else 1318 else
1319 { 1319 {
1320 throw new WixException(WixErrors.InvalidSubExpression(this.Context.CurrentSourceLineNumber, expression, originalExpression)); 1320 throw new WixException(ErrorMessages.InvalidSubExpression(this.Context.CurrentSourceLineNumber, expression, originalExpression));
1321 } 1321 }
1322 } 1322 }
1323 1323
@@ -1351,7 +1351,7 @@ namespace WixToolset.Core
1351 { 1351 {
1352 if (1023 < this.CurrentFileStack.Count) 1352 if (1023 < this.CurrentFileStack.Count)
1353 { 1353 {
1354 throw new WixException(WixErrors.TooDeeplyIncluded(this.Context.CurrentSourceLineNumber, this.CurrentFileStack.Count)); 1354 throw new WixException(ErrorMessages.TooDeeplyIncluded(this.Context.CurrentSourceLineNumber, this.CurrentFileStack.Count));
1355 } 1355 }
1356 1356
1357 this.CurrentFileStack.Push(fileName); 1357 this.CurrentFileStack.Push(fileName);