diff options
author | Rob Mensching <rob@firegiant.com> | 2022-02-03 10:27:11 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-02-03 11:21:49 -0800 |
commit | 3a9a2a4a1a009ac6ee7a4e15c5fe85d04a115650 (patch) | |
tree | 860a98cf05bd05aeff3360ca0c1533876f07c72f | |
parent | fbaf8ae6972cbeac4500ba49235a6b5cb4cb87e3 (diff) | |
download | wix-3a9a2a4a1a009ac6ee7a4e15c5fe85d04a115650.tar.gz wix-3a9a2a4a1a009ac6ee7a4e15c5fe85d04a115650.tar.bz2 wix-3a9a2a4a1a009ac6ee7a4e15c5fe85d04a115650.zip |
Error on invalid Control/@Type attribute values
4 files changed, 58 insertions, 45 deletions
diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index 86504f60..80738f5e 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs | |||
@@ -749,49 +749,9 @@ namespace WixToolset.Data | |||
749 | return Message(sourceLineNumbers, Ids.IllegalAttributeInMergeModule, "The {0}/@{1} attribute cannot be specified in a merge module.", elementName, attributeName); | 749 | return Message(sourceLineNumbers, Ids.IllegalAttributeInMergeModule, "The {0}/@{1} attribute cannot be specified in a merge module.", elementName, attributeName); |
750 | } | 750 | } |
751 | 751 | ||
752 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1) | 752 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, params string[] legalValues) |
753 | { | 753 | { |
754 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}'.", elementName, attributeName, value, legalValue1); | 754 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}'.", elementName, attributeName, value, String.Join(",", legalValues)); |
755 | } | ||
756 | |||
757 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2) | ||
758 | { | ||
759 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', or '{4}'.", elementName, attributeName, value, legalValue1, legalValue2); | ||
760 | } | ||
761 | |||
762 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3) | ||
763 | { | ||
764 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', or '{5}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3); | ||
765 | } | ||
766 | |||
767 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3, string legalValue4) | ||
768 | { | ||
769 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', '{5}', or '{6}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3, legalValue4); | ||
770 | } | ||
771 | |||
772 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3, string legalValue4, string legalValue5) | ||
773 | { | ||
774 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', '{5}', '{6}', or '{7}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3, legalValue4, legalValue5); | ||
775 | } | ||
776 | |||
777 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3, string legalValue4, string legalValue5, string legalValue6) | ||
778 | { | ||
779 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', '{5}', '{6}', '{7}', or '{8}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3, legalValue4, legalValue5, legalValue6); | ||
780 | } | ||
781 | |||
782 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3, string legalValue4, string legalValue5, string legalValue6, string legalValue7) | ||
783 | { | ||
784 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', or '{9}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3, legalValue4, legalValue5, legalValue6, legalValue7); | ||
785 | } | ||
786 | |||
787 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3, string legalValue4, string legalValue5, string legalValue6, string legalValue7, string legalValue8) | ||
788 | { | ||
789 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', or '{10}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3, legalValue4, legalValue5, legalValue6, legalValue7, legalValue8); | ||
790 | } | ||
791 | |||
792 | public static Message IllegalAttributeValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string legalValue1, string legalValue2, string legalValue3, string legalValue4, string legalValue5, string legalValue6, string legalValue7, string legalValue8, string legalValue9, string legalValue10, string legalValue11, string legalValue12, string legalValue13, string legalValue14, string legalValue15, string legalValue16, string legalValue17, string legalValue18, string legalValue19, string legalValue20, string legalValue21, string legalValue22, string legalValue23, string legalValue24, string legalValue25, string legalValue26) | ||
793 | { | ||
794 | return Message(sourceLineNumbers, Ids.IllegalAttributeValue, "The {0}/@{1} attribute's value, '{2}', is not one of the legal options: '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}', '{23}', '{24}', '{25}', '{26}', '{27}', or '{28}'.", elementName, attributeName, value, legalValue1, legalValue2, legalValue3, legalValue4, legalValue5, legalValue6, legalValue7, legalValue8, legalValue9, legalValue10, legalValue11, legalValue12, legalValue13, legalValue14, legalValue15, legalValue16, legalValue17, legalValue18, legalValue19, legalValue20, legalValue21, legalValue22, legalValue23, legalValue24, legalValue25, legalValue26); | ||
795 | } | 755 | } |
796 | 756 | ||
797 | public static Message IllegalAttributeValueWhenNested(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string attrivuteValue, string parentElementName) | 757 | public static Message IllegalAttributeValueWhenNested(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string attrivuteValue, string parentElementName) |
diff --git a/src/wix/WixToolset.Core/Compiler_UI.cs b/src/wix/WixToolset.Core/Compiler_UI.cs index c07ca1dd..aff978c7 100644 --- a/src/wix/WixToolset.Core/Compiler_UI.cs +++ b/src/wix/WixToolset.Core/Compiler_UI.cs | |||
@@ -1186,9 +1186,11 @@ namespace WixToolset.Core | |||
1186 | specialAttributes = VolumeControlAttributes; | 1186 | specialAttributes = VolumeControlAttributes; |
1187 | break; | 1187 | break; |
1188 | default: | 1188 | default: |
1189 | specialAttributes = null; | 1189 | this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, typeAttribute.Name.LocalName, controlType, |
1190 | notTabbable = true; | 1190 | "Billboard", "Bitmap", "CheckBox", "ComboBox", "DirectoryCombo", "DirectoryList", "Edit", "GroupBox", |
1191 | break; | 1191 | "Hyperlink", "Icon", "Line", "ListBox", "ListView", "MaskedEdit", "PathEdit", "ProgressBar", "PushButton", |
1192 | "RadioButtonGroup", "ScrollableText", "SelectionTree", "Text", "VolumeCostList", "VolumeSelectCombo")); | ||
1193 | return; | ||
1192 | } | 1194 | } |
1193 | 1195 | ||
1194 | foreach (var attrib in node.Attributes()) | 1196 | foreach (var attrib in node.Attributes()) |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/UI/DialogWithInvalidControlType.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/UI/DialogWithInvalidControlType.wxs new file mode 100644 index 00000000..cb9a1ffc --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/UI/DialogWithInvalidControlType.wxs | |||
@@ -0,0 +1,20 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <Fragment> | ||
3 | <UI Id="CustomDialog"> | ||
4 | <Dialog Id="SomeDialog" Width="100" Height="100"> | ||
5 | <!-- Correct would be Type="Hyperlink", notice the lowercase 'l'. --> | ||
6 | <Control Id="WebLink" Type="HyperLink" Width="70" Height="12" X="10" Y="10" Transparent="yes" NoPrefix="yes" Text="Some text that would be a hyperlink." /> | ||
7 | </Dialog> | ||
8 | |||
9 | <InstallUISequence> | ||
10 | <Show Dialog="SomeDialog" Before="FirstDialog" Overridable="yes" Condition="NOT Installed" /> | ||
11 | </InstallUISequence> | ||
12 | </UI> | ||
13 | |||
14 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
15 | <Component> | ||
16 | <File Source="test.txt" /> | ||
17 | </Component> | ||
18 | </ComponentGroup> | ||
19 | </Fragment> | ||
20 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/UIFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/UIFixture.cs index 8218ed67..728e6c9e 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/UIFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/UIFixture.cs | |||
@@ -65,5 +65,36 @@ namespace WixToolsetTest.CoreIntegration | |||
65 | }, results); | 65 | }, results); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | |||
69 | [Fact] | ||
70 | public void CanErrorWithInvalidControlType() | ||
71 | { | ||
72 | var folder = TestData.Get(@"TestData"); | ||
73 | |||
74 | using (var fs = new DisposableFileSystem()) | ||
75 | { | ||
76 | var baseFolder = fs.GetFolder(); | ||
77 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
78 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
79 | |||
80 | var result = WixRunner.Execute(new[] | ||
81 | { | ||
82 | "build", | ||
83 | Path.Combine(folder, "UI", "DialogWithInvalidControlType.wxs"), | ||
84 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
85 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
86 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
87 | "-intermediateFolder", intermediateFolder, | ||
88 | "-o", msiPath, | ||
89 | }); | ||
90 | |||
91 | var errors = result.Messages.Where(m => m.Level == MessageLevel.Error).ToList(); | ||
92 | Assert.Equal(new[] | ||
93 | { | ||
94 | 21, | ||
95 | 52 | ||
96 | }, errors.Select(e => e.Id).ToArray()); | ||
97 | } | ||
98 | } | ||
68 | } | 99 | } |
69 | } | 100 | } |