Remove explicit auto-GUIDs
Rob Mensching committed
Jun 23, 2020 at 01:11 UTC
9c235551b2fb961cf10ecb307c252fd5de377513
7 files changed
+30
-7
src/WixToolset.Converters/Wix3Converter.cs
+23
@@ -407,6 +407,15 @@ namespace WixToolset.Converters
407
408
private void ConvertComponentElement(XElement element)
409
{
410
+ var guid = element.Attribute("Guid");
411
+ if (guid != null && guid.Value == "*")
412
+ {
413
+ if (this.OnError(ConverterTestType.AutoGuidUnnecessary, element, "Using '*' for the Component Guid attribute is unnecessary. Remove the attribute to remove the redundancy."))
414
+ {
415
+ guid.Remove();
416
+ }
417
+ }
418
+
419
var xCondition = element.Element(ConditionElementName);
420
if (xCondition != null)
421
{
@@ -523,6 +532,15 @@ namespace WixToolset.Converters
532
533
private void ConvertProductElement(XElement element)
534
{
535
+ var id = element.Attribute("Id");
536
+ if (id != null && id.Value == "*")
537
+ {
538
+ if (this.OnError(ConverterTestType.AutoGuidUnnecessary, element, "Using '*' for the Product Id attribute is unnecessary. Remove the attribute to remove the redundancy."))
539
+ {
540
+ id.Remove();
541
+ }
542
+ }
543
+
544
var xCondition = element.Element(ConditionElementName);
545
if (xCondition != null)
546
{
@@ -1029,6 +1047,11 @@ namespace WixToolset.Converters
1047
/// Inner text value should move to an attribute.
1048
/// </summary>
1049
InnerTextDeprecated,
1050
+
1051
+ /// <summary>
1052
+ /// Explicit auto-GUID unnecessary.
1053
+ /// </summary>
1054
+ AutoGuidUnnecessary,
1055
}
1056
}
1057
}
src/test/WixToolsetTest.Converters/ConditionFixture.cs
+2
-2
@@ -171,7 +171,7 @@ namespace WixToolsetTest.Converters
171
"<?xml version=\"1.0\" encoding=\"utf-16\"?>",
172
"<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
173
" <Fragment>",
174
- " <Component Id='Comp1' Directory='ApplicationFolder'>",
174
+ " <Component Id='Comp1' Guid='*' Directory='ApplicationFolder'>",
175
" <PermissionEx Sddl='sddl'>",
176
" <Condition>1<2</Condition>",
177
" </PermissionEx>",
@@ -199,7 +199,7 @@ namespace WixToolsetTest.Converters
199
var converter = new Wix3Converter(messaging, 2, null, null);
200
201
var errors = converter.ConvertDocument(document);
202
- Assert.Equal(3, errors);
202
+ Assert.Equal(4, errors);
203
204
var actualLines = UnformattedDocumentLines(document);
205
CompareLineByLine(expected, actualLines);
src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
+1
-1
@@ -58,7 +58,7 @@ namespace WixToolsetTest.Converters
58
var converter = new Wix3Converter(messaging, 4);
59
var errors = converter.ConvertFile(targetFile, true);
60
61
- Assert.Equal(5, errors);
61
+ Assert.Equal(6, errors);
62
63
var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
64
var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n");
src/test/WixToolsetTest.Converters/TestData/Preprocessor/ConvertedPreprocessor.wxs
+1
-1
@@ -6,7 +6,7 @@
6
<?include WixVer.wxi ?>
7
8
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
9
- <Product Id="*" Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
9
+ <Product Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
10
<Package Compressed="yes" InstallerVersion="200" SummaryCodepage="1252" InstallScope="perMachine" />
11
<swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
12
src/test/WixToolsetTest.Converters/TestData/QtExec.bad/v4_expected.wxs
+1
-1
@@ -6,7 +6,7 @@
6
<?include WixVer.wxi ?>
7
8
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
9
- <Product Id="*" Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
9
+ <Product Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
10
<Package Compressed="yes" InstallerVersion="200" SummaryCodepage="1252" InstallScope="perMachine" />
11
<swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
12
src/test/WixToolsetTest.Converters/TestData/QtExec/v4_expected.wxs
+1
-1
@@ -6,7 +6,7 @@
6
<?include WixVer.wxi ?>
7
8
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
9
- <Product Id="*" Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
9
+ <Product Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
10
<Package Compressed="yes" InstallerVersion="200" SummaryCodepage="1252" InstallScope="perMachine" />
11
<swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
12
src/test/WixToolsetTest.Converters/TestData/SingleFile/ConvertedSingleFile.wxs
+1
-1
@@ -6,7 +6,7 @@
6
<?include WixVer.wxi ?>
7
8
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
9
- <Product Id="*" Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
9
+ <Product Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
10
<Package Compressed="yes" InstallerVersion="200" SummaryCodepage="1252" InstallScope="perMachine" />
11
<swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
12