@joebigelow / wix / commits / cdef9c07

Convert Feature/@Absent=disallow to AllowAbsent=no.

Bob Arnson committed Aug 31, 2020 at 16:33 UTC cdef9c078068b7dc23b348b2142dc13dd5a936fb
2 files changed +37 -5
src/WixToolset.Converters/WixConverter.cs
+4 -4
@@ -560,9 +560,9 @@ namespace WixToolset.Converters
560 if (xAbsent != null &&
561 this.OnError(ConverterTestType.FeatureAbsentAttributeReplaced, element, "The Feature element's Absent attribute has been replaced with the AllowAbsent attribute. Use the 'AllowAbsent' attribute instead."))
562 {
563 - if (xAbsent.Value == "allow")
563 + if (xAbsent.Value == "disallow")
564 {
565 - element.Add(new XAttribute("AllowAbsent", "yes"));
565 + element.Add(new XAttribute("AllowAbsent", "no"));
566 }
567 xAbsent.Remove();
568 }
@@ -571,12 +571,12 @@ namespace WixToolset.Converters
571 if (xAllowAdvertise != null)
572 {
573 if ((xAllowAdvertise.Value == "system" || xAllowAdvertise.Value == "allow") &&
574 - this.OnError(ConverterTestType.FeatureAllowAdvertiseValueDeprecated, element, "The AllowAdvertise attribute's '{0}' value deprecated. Set the value to 'yes' instead.", xAllowAdvertise.Value))
574 + this.OnError(ConverterTestType.FeatureAllowAdvertiseValueDeprecated, element, "The AllowAdvertise attribute's '{0}' value is deprecated. Set the value to 'yes' instead.", xAllowAdvertise.Value))
575 {
576 xAllowAdvertise.Value = "yes";
577 }
578 else if (xAllowAdvertise.Value == "disallow" &&
579 - this.OnError(ConverterTestType.FeatureAllowAdvertiseValueDeprecated, element, "The AllowAdvertise attribute's '{0}' value deprecated. Remove the value instead.", xAllowAdvertise.Value))
579 + this.OnError(ConverterTestType.FeatureAllowAdvertiseValueDeprecated, element, "The AllowAdvertise attribute's '{0}' value is deprecated. Remove the value instead.", xAllowAdvertise.Value))
580 {
581 xAllowAdvertise.Remove();
582 }
src/test/WixToolsetTest.Converters/FeatureFixture.cs
+33 -1
@@ -25,7 +25,7 @@ namespace WixToolsetTest.Converters
25 {
26 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
27 " <Fragment>",
28 - " <Feature AllowAdvertise=\"yes\" AllowAbsent=\"yes\" />",
28 + " <Feature AllowAdvertise=\"yes\" />",
29 " </Fragment>",
30 "</Wix>"
31 };
@@ -42,6 +42,38 @@ namespace WixToolsetTest.Converters
42 CompareLineByLine(expected, actualLines);
43 }
44
45 + [Fact]
46 + public void FixDisallowAttributes()
47 + {
48 + var parse = String.Join(Environment.NewLine,
49 + "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
50 + "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
51 + " <Fragment>",
52 + " <Feature Absent='disallow' AllowAdvertise='no' />",
53 + " </Fragment>",
54 + "</Wix>");
55 +
56 + var expected = new[]
57 + {
58 + "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
59 + " <Fragment>",
60 + " <Feature AllowAdvertise=\"no\" AllowAbsent=\"no\" />",
61 + " </Fragment>",
62 + "</Wix>"
63 + };
64 +
65 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
66 +
67 + var messaging = new MockMessaging();
68 + var converter = new WixConverter(messaging, 2, null, null);
69 +
70 + var errors = converter.ConvertDocument(document);
71 + Assert.Equal(3, errors);
72 +
73 + var actualLines = UnformattedDocumentLines(document);
74 + CompareLineByLine(expected, actualLines);
75 + }
76 +
77 [Fact]
78 public void RemoveDeprecatedAllowAdvertiseAttributes()
79 {