diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-02-11 14:40:06 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-02-11 14:41:50 -0800 |
| commit | 007e4dfe58293212180a617da25025e52677eee8 (patch) | |
| tree | 782f05066561436c319f10273bb821a3794ab325 /src | |
| parent | 7ff5ffb753fc0f576c24b0faa5d03b6d85b0f238 (diff) | |
| download | wix-007e4dfe58293212180a617da25025e52677eee8.tar.gz wix-007e4dfe58293212180a617da25025e52677eee8.tar.bz2 wix-007e4dfe58293212180a617da25025e52677eee8.zip | |
Preserve unconvertable Win64 attribute content
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Converters/WixConverter.cs | 36 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Converters/BitnessFixture.cs | 8 |
2 files changed, 35 insertions, 9 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 18cd7115..4d5564b4 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs | |||
| @@ -636,8 +636,8 @@ namespace WixToolset.Converters | |||
| 636 | var win64 = element.Attribute("Win64"); | 636 | var win64 = element.Attribute("Win64"); |
| 637 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) | 637 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) |
| 638 | { | 638 | { |
| 639 | var value = win64.Value; | 639 | var value = this.UpdateWin64ValueToBitnessValue(win64); |
| 640 | element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32")); | 640 | element.Add(new XAttribute("Bitness", value)); |
| 641 | win64.Remove(); | 641 | win64.Remove(); |
| 642 | } | 642 | } |
| 643 | } | 643 | } |
| @@ -755,8 +755,8 @@ namespace WixToolset.Converters | |||
| 755 | var win64 = element.Attribute("Win64"); | 755 | var win64 = element.Attribute("Win64"); |
| 756 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) | 756 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) |
| 757 | { | 757 | { |
| 758 | var value = win64.Value; | 758 | var value = this.UpdateWin64ValueToBitnessValue(win64); |
| 759 | element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32")); | 759 | element.Add(new XAttribute("Bitness", value)); |
| 760 | win64.Remove(); | 760 | win64.Remove(); |
| 761 | } | 761 | } |
| 762 | } | 762 | } |
| @@ -1104,8 +1104,8 @@ namespace WixToolset.Converters | |||
| 1104 | var win64 = element.Attribute("Win64"); | 1104 | var win64 = element.Attribute("Win64"); |
| 1105 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) | 1105 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) |
| 1106 | { | 1106 | { |
| 1107 | var value = win64.Value; | 1107 | var value = this.UpdateWin64ValueToBitnessValue(win64); |
| 1108 | element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32")); | 1108 | element.Add(new XAttribute("Bitness", value)); |
| 1109 | win64.Remove(); | 1109 | win64.Remove(); |
| 1110 | } | 1110 | } |
| 1111 | } | 1111 | } |
| @@ -1296,8 +1296,8 @@ namespace WixToolset.Converters | |||
| 1296 | var win64 = element.Attribute("Win64"); | 1296 | var win64 = element.Attribute("Win64"); |
| 1297 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) | 1297 | if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead.")) |
| 1298 | { | 1298 | { |
| 1299 | var value = win64.Value; | 1299 | var value = this.UpdateWin64ValueToBitnessValue(win64); |
| 1300 | element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32")); | 1300 | element.Add(new XAttribute("Bitness", value)); |
| 1301 | win64.Remove(); | 1301 | win64.Remove(); |
| 1302 | } | 1302 | } |
| 1303 | 1303 | ||
| @@ -1341,6 +1341,21 @@ namespace WixToolset.Converters | |||
| 1341 | } | 1341 | } |
| 1342 | } | 1342 | } |
| 1343 | 1343 | ||
| 1344 | private string UpdateWin64ValueToBitnessValue(XAttribute xWin64Attribute) | ||
| 1345 | { | ||
| 1346 | var value = xWin64Attribute.Value ?? String.Empty; | ||
| 1347 | switch (value) | ||
| 1348 | { | ||
| 1349 | case "yes": | ||
| 1350 | return "always64"; | ||
| 1351 | case "no": | ||
| 1352 | return "always32"; | ||
| 1353 | default: | ||
| 1354 | this.OnError(ConverterTestType.Win64AttributeRenameCannotBeAutomatic, xWin64Attribute, "Breaking change: The Win64 attribute's value '{0}' cannot be converted automatically to the new Bitness attribute.", value); | ||
| 1355 | return value; | ||
| 1356 | } | ||
| 1357 | } | ||
| 1358 | |||
| 1344 | private IEnumerable<ConverterTestType> YieldConverterTypes(IEnumerable<string> types) | 1359 | private IEnumerable<ConverterTestType> YieldConverterTypes(IEnumerable<string> types) |
| 1345 | { | 1360 | { |
| 1346 | if (null != types) | 1361 | if (null != types) |
| @@ -1795,6 +1810,11 @@ namespace WixToolset.Converters | |||
| 1795 | /// The Win64 attribute has been renamed. Use the Bitness attribute instead. | 1810 | /// The Win64 attribute has been renamed. Use the Bitness attribute instead. |
| 1796 | /// </summary> | 1811 | /// </summary> |
| 1797 | Win64AttributeRenamed, | 1812 | Win64AttributeRenamed, |
| 1813 | |||
| 1814 | /// <summary> | ||
| 1815 | /// Breaking change: The Win64 attribute's value '{0}' cannot be converted automatically to the new Bitness attribute. | ||
| 1816 | /// </summary> | ||
| 1817 | Win64AttributeRenameCannotBeAutomatic, | ||
| 1798 | } | 1818 | } |
| 1799 | } | 1819 | } |
| 1800 | } | 1820 | } |
diff --git a/src/test/WixToolsetTest.Converters/BitnessFixture.cs b/src/test/WixToolsetTest.Converters/BitnessFixture.cs index 9996806d..e45a9388 100644 --- a/src/test/WixToolsetTest.Converters/BitnessFixture.cs +++ b/src/test/WixToolsetTest.Converters/BitnessFixture.cs | |||
| @@ -27,6 +27,9 @@ namespace WixToolsetTest.Converters | |||
| 27 | " <Component Win64='yes'>", | 27 | " <Component Win64='yes'>", |
| 28 | " <File Source='64bit.exe' />", | 28 | " <File Source='64bit.exe' />", |
| 29 | " </Component>", | 29 | " </Component>", |
| 30 | " <Component Win64='$(var.Win64)'>", | ||
| 31 | " <File Source='unconvert.exe' />", | ||
| 32 | " </Component>", | ||
| 30 | " </Fragment>", | 33 | " </Fragment>", |
| 31 | "</Wix>"); | 34 | "</Wix>"); |
| 32 | 35 | ||
| @@ -43,6 +46,9 @@ namespace WixToolsetTest.Converters | |||
| 43 | " <Component Bitness=\"always64\">", | 46 | " <Component Bitness=\"always64\">", |
| 44 | " <File Id=\"_64bit.exe\" Source=\"64bit.exe\" />", | 47 | " <File Id=\"_64bit.exe\" Source=\"64bit.exe\" />", |
| 45 | " </Component>", | 48 | " </Component>", |
| 49 | " <Component Bitness=\"$(var.Win64)\">", | ||
| 50 | " <File Id=\"unconvert.exe\" Source=\"unconvert.exe\" />", | ||
| 51 | " </Component>", | ||
| 46 | " </Fragment>", | 52 | " </Fragment>", |
| 47 | "</Wix>" | 53 | "</Wix>" |
| 48 | }; | 54 | }; |
| @@ -53,7 +59,7 @@ namespace WixToolsetTest.Converters | |||
| 53 | var converter = new WixConverter(messaging, 2, null, null); | 59 | var converter = new WixConverter(messaging, 2, null, null); |
| 54 | 60 | ||
| 55 | var errors = converter.ConvertDocument(document); | 61 | var errors = converter.ConvertDocument(document); |
| 56 | Assert.Equal(7, errors); | 62 | Assert.Equal(10, errors); |
| 57 | 63 | ||
| 58 | var actualLines = UnformattedDocumentLines(document); | 64 | var actualLines = UnformattedDocumentLines(document); |
| 59 | WixAssert.CompareLineByLine(expected, actualLines); | 65 | WixAssert.CompareLineByLine(expected, actualLines); |
