aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/CompilerCore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/CompilerCore.cs')
-rw-r--r--src/WixToolset.Core/CompilerCore.cs66
1 files changed, 32 insertions, 34 deletions
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs
index 26c19acc..7cb7b703 100644
--- a/src/WixToolset.Core/CompilerCore.cs
+++ b/src/WixToolset.Core/CompilerCore.cs
@@ -8,14 +8,11 @@ namespace WixToolset.Core
8 using System.Diagnostics; 8 using System.Diagnostics;
9 using System.Diagnostics.CodeAnalysis; 9 using System.Diagnostics.CodeAnalysis;
10 using System.Globalization; 10 using System.Globalization;
11 using System.IO;
12 using System.Reflection; 11 using System.Reflection;
13 using System.Security.Cryptography;
14 using System.Text; 12 using System.Text;
15 using System.Text.RegularExpressions; 13 using System.Text.RegularExpressions;
16 using System.Xml.Linq; 14 using System.Xml.Linq;
17 using WixToolset.Data; 15 using WixToolset.Data;
18 using WixToolset.Data.Tuples;
19 using WixToolset.Extensibility; 16 using WixToolset.Extensibility;
20 using WixToolset.Extensibility.Services; 17 using WixToolset.Extensibility.Services;
21 using Wix = WixToolset.Data.Serialize; 18 using Wix = WixToolset.Data.Serialize;
@@ -128,10 +125,10 @@ namespace WixToolset.Core
128 "REMOVE" 125 "REMOVE"
129 }); 126 });
130 127
131 private Dictionary<XNamespace, ICompilerExtension> extensions; 128 private readonly Dictionary<XNamespace, ICompilerExtension> extensions;
132 private IParseHelper parseHelper; 129 private readonly IParseHelper parseHelper;
133 private Intermediate intermediate; 130 private readonly Intermediate intermediate;
134 131 private readonly IMessaging messaging;
135 private HashSet<string> activeSectionInlinedDirectoryIds; 132 private HashSet<string> activeSectionInlinedDirectoryIds;
136 private HashSet<string> activeSectionSimpleReferences; 133 private HashSet<string> activeSectionSimpleReferences;
137 134
@@ -140,11 +137,12 @@ namespace WixToolset.Core
140 /// </summary> 137 /// </summary>
141 /// <param name="intermediate">The Intermediate object representing compiled source document.</param> 138 /// <param name="intermediate">The Intermediate object representing compiled source document.</param>
142 /// <param name="extensions">The WiX extensions collection.</param> 139 /// <param name="extensions">The WiX extensions collection.</param>
143 internal CompilerCore(Intermediate intermediate, IParseHelper parseHelper, Dictionary<XNamespace, ICompilerExtension> extensions) 140 internal CompilerCore(Intermediate intermediate, IMessaging messaging, IParseHelper parseHelper, Dictionary<XNamespace, ICompilerExtension> extensions)
144 { 141 {
145 this.extensions = extensions; 142 this.extensions = extensions;
146 this.parseHelper = parseHelper; 143 this.parseHelper = parseHelper;
147 this.intermediate = intermediate; 144 this.intermediate = intermediate;
145 this.messaging = messaging;
148 } 146 }
149 147
150 /// <summary> 148 /// <summary>
@@ -157,7 +155,7 @@ namespace WixToolset.Core
157 /// Gets whether the compiler core encountered an error while processing. 155 /// Gets whether the compiler core encountered an error while processing.
158 /// </summary> 156 /// </summary>
159 /// <value>Flag if core encountered an error during processing.</value> 157 /// <value>Flag if core encountered an error during processing.</value>
160 public bool EncounteredError => Messaging.Instance.EncounteredError; 158 public bool EncounteredError => this.messaging.EncounteredError;
161 159
162 /// <summary> 160 /// <summary>
163 /// Gets or sets the option to show pedantic messages. 161 /// Gets or sets the option to show pedantic messages.
@@ -511,7 +509,7 @@ namespace WixToolset.Core
511 } 509 }
512 catch (NotSupportedException) 510 catch (NotSupportedException)
513 { 511 {
514 this.OnMessage(WixErrors.IllegalCodepageAttribute(sourceLineNumbers, value, attribute.Parent.Name.LocalName, attribute.Name.LocalName)); 512 this.Write(ErrorMessages.IllegalCodepageAttribute(sourceLineNumbers, value, attribute.Parent.Name.LocalName, attribute.Name.LocalName));
515 } 513 }
516 514
517 return CompilerConstants.IllegalInteger; 515 return CompilerConstants.IllegalInteger;
@@ -548,11 +546,11 @@ namespace WixToolset.Core
548 catch (NotSupportedException) 546 catch (NotSupportedException)
549 { 547 {
550 // not a valid windows code page 548 // not a valid windows code page
551 this.OnMessage(WixErrors.IllegalCodepageAttribute(sourceLineNumbers, value, attribute.Parent.Name.LocalName, attribute.Name.LocalName)); 549 this.Write(ErrorMessages.IllegalCodepageAttribute(sourceLineNumbers, value, attribute.Parent.Name.LocalName, attribute.Name.LocalName));
552 } 550 }
553 catch (WixException e) 551 catch (WixException e)
554 { 552 {
555 this.OnMessage(e.Error); 553 this.messaging.Write(e.Error);
556 } 554 }
557 555
558 return null; 556 return null;
@@ -612,15 +610,15 @@ namespace WixToolset.Core
612 } 610 }
613 catch (ArgumentOutOfRangeException) 611 catch (ArgumentOutOfRangeException)
614 { 612 {
615 this.OnMessage(WixErrors.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 613 this.Write(ErrorMessages.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
616 } 614 }
617 catch (FormatException) 615 catch (FormatException)
618 { 616 {
619 this.OnMessage(WixErrors.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 617 this.Write(ErrorMessages.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
620 } 618 }
621 catch (OverflowException) 619 catch (OverflowException)
622 { 620 {
623 this.OnMessage(WixErrors.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 621 this.Write(ErrorMessages.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
624 } 622 }
625 } 623 }
626 624
@@ -661,11 +659,11 @@ namespace WixToolset.Core
661 659
662 if (CompilerConstants.IntegerNotSet == integer || CompilerConstants.IllegalInteger == integer) 660 if (CompilerConstants.IntegerNotSet == integer || CompilerConstants.IllegalInteger == integer)
663 { 661 {
664 this.OnMessage(WixErrors.IntegralValueSentinelCollision(sourceLineNumbers, integer)); 662 this.Write(ErrorMessages.IntegralValueSentinelCollision(sourceLineNumbers, integer));
665 } 663 }
666 else if (minimum > integer || maximum < integer) 664 else if (minimum > integer || maximum < integer)
667 { 665 {
668 this.OnMessage(WixErrors.IntegralValueOutOfRange(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, integer, minimum, maximum)); 666 this.Write(ErrorMessages.IntegralValueOutOfRange(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, integer, minimum, maximum));
669 integer = CompilerConstants.IllegalInteger; 667 integer = CompilerConstants.IllegalInteger;
670 } 668 }
671 669
@@ -673,11 +671,11 @@ namespace WixToolset.Core
673 } 671 }
674 catch (FormatException) 672 catch (FormatException)
675 { 673 {
676 this.OnMessage(WixErrors.IllegalIntegerValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 674 this.Write(ErrorMessages.IllegalIntegerValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
677 } 675 }
678 catch (OverflowException) 676 catch (OverflowException)
679 { 677 {
680 this.OnMessage(WixErrors.IllegalIntegerValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 678 this.Write(ErrorMessages.IllegalIntegerValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
681 } 679 }
682 } 680 }
683 } 681 }
@@ -768,7 +766,7 @@ namespace WixToolset.Core
768 // Previous code never returned 'NotSet'! 766 // Previous code never returned 'NotSet'!
769 break; 767 break;
770 default: 768 default:
771 this.OnMessage(WixErrors.IllegalYesNoAlwaysValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 769 this.Write(ErrorMessages.IllegalYesNoAlwaysValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
772 break; 770 break;
773 } 771 }
774 } 772 }
@@ -796,11 +794,11 @@ namespace WixToolset.Core
796 { 794 {
797 if (!this.IsValidShortFilename(value, allowWildcards) && !this.IsValidLocIdentifier(value)) 795 if (!this.IsValidShortFilename(value, allowWildcards) && !this.IsValidLocIdentifier(value))
798 { 796 {
799 this.OnMessage(WixErrors.IllegalShortFilename(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 797 this.Write(ErrorMessages.IllegalShortFilename(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
800 } 798 }
801 else if (CompilerCore.IsAmbiguousFilename(value)) 799 else if (CompilerCore.IsAmbiguousFilename(value))
802 { 800 {
803 this.OnMessage(WixWarnings.AmbiguousFileOrDirectoryName(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); 801 this.Write(WarningMessages.AmbiguousFileOrDirectoryName(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
804 } 802 }
805 } 803 }
806 804
@@ -854,12 +852,12 @@ namespace WixToolset.Core
854 // TODO: Find a way to expose the valid values programatically! 852 // TODO: Find a way to expose the valid values programatically!
855 if (allowHkmu) 853 if (allowHkmu)
856 { 854 {
857 this.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, 855 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
858 "HKMU", "HKCR", "HKCU", "HKLM", "HKU")); 856 "HKMU", "HKCR", "HKCU", "HKLM", "HKU"));
859 } 857 }
860 else 858 else
861 { 859 {
862 this.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, 860 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
863 "HKCR", "HKCU", "HKLM", "HKU")); 861 "HKCR", "HKCU", "HKLM", "HKU"));
864 } 862 }
865 } 863 }
@@ -926,7 +924,7 @@ namespace WixToolset.Core
926 if (Wix.InstallUninstallType.IllegalValue == installUninstall) 924 if (Wix.InstallUninstallType.IllegalValue == installUninstall)
927 { 925 {
928 // TODO: Find a way to expose the valid values programatically! 926 // TODO: Find a way to expose the valid values programatically!
929 this.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, 927 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
930 "install", "uninstall", "both")); 928 "install", "uninstall", "both"));
931 } 929 }
932 } 930 }
@@ -951,7 +949,7 @@ namespace WixToolset.Core
951 result = Wix.ExitType.IllegalValue; 949 result = Wix.ExitType.IllegalValue;
952 950
953 // TODO: Find a way to expose the valid values programatically! 951 // TODO: Find a way to expose the valid values programatically!
954 this.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, 952 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
955 "success", "cancel", "error", "suspend")); 953 "success", "cancel", "error", "suspend"));
956 } 954 }
957 955
@@ -974,7 +972,7 @@ namespace WixToolset.Core
974 if (CompilerCore.BuiltinBundleVariables.Contains(value)) 972 if (CompilerCore.BuiltinBundleVariables.Contains(value))
975 { 973 {
976 string illegalValues = CompilerCore.CreateValueList(ValueListKind.Or, CompilerCore.BuiltinBundleVariables); 974 string illegalValues = CompilerCore.CreateValueList(ValueListKind.Or, CompilerCore.BuiltinBundleVariables);
977 this.OnMessage(WixErrors.IllegalAttributeValueWithIllegalList(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, illegalValues)); 975 this.Write(ErrorMessages.IllegalAttributeValueWithIllegalList(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, illegalValues));
978 } 976 }
979 } 977 }
980 978
@@ -997,7 +995,7 @@ namespace WixToolset.Core
997 if (CompilerCore.DisallowedMsiProperties.Contains(value)) 995 if (CompilerCore.DisallowedMsiProperties.Contains(value))
998 { 996 {
999 string illegalValues = CompilerCore.CreateValueList(ValueListKind.Or, CompilerCore.DisallowedMsiProperties); 997 string illegalValues = CompilerCore.CreateValueList(ValueListKind.Or, CompilerCore.DisallowedMsiProperties);
1000 this.OnMessage(WixErrors.DisallowedMsiProperty(sourceLineNumbers, value, illegalValues)); 998 this.Write(ErrorMessages.DisallowedMsiProperty(sourceLineNumbers, value, illegalValues));
1001 } 999 }
1002 } 1000 }
1003 1001
@@ -1099,12 +1097,12 @@ namespace WixToolset.Core
1099 } 1097 }
1100 1098
1101 /// <summary> 1099 /// <summary>
1102 /// Sends a message to the message delegate if there is one. 1100 /// Sends a message.
1103 /// </summary> 1101 /// </summary>
1104 /// <param name="mea">Message event arguments.</param> 1102 /// <param name="message">Message to write.</param>
1105 public void OnMessage(MessageEventArgs e) 1103 public void Write(Message message)
1106 { 1104 {
1107 Messaging.Instance.OnMessage(e); 1105 this.messaging.Write(message);
1108 } 1106 }
1109 1107
1110 /// <summary> 1108 /// <summary>
@@ -1128,11 +1126,11 @@ namespace WixToolset.Core
1128 { 1126 {
1129 if (this.GetType().Assembly.Equals(caller)) 1127 if (this.GetType().Assembly.Equals(caller))
1130 { 1128 {
1131 this.OnMessage(WixErrors.InsufficientVersion(sourceLineNumbers, versionCurrent, versionRequired)); 1129 this.Write(ErrorMessages.InsufficientVersion(sourceLineNumbers, versionCurrent, versionRequired));
1132 } 1130 }
1133 else 1131 else
1134 { 1132 {
1135 this.OnMessage(WixErrors.InsufficientVersion(sourceLineNumbers, versionCurrent, versionRequired, name.Name)); 1133 this.Write(ErrorMessages.InsufficientVersion(sourceLineNumbers, versionCurrent, versionRequired, name.Name));
1136 } 1134 }
1137 } 1135 }
1138 } 1136 }