aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-07-01 01:59:21 -0700
committerRob Mensching <rob@firegiant.com>2020-07-01 11:26:56 -0700
commit3f0af880a3d8a41e1a6ac342f8fba06d22b223a0 (patch)
tree3f55ef78b9dd33cb17992628ceff563e2802ceaa /src
parent181aa7076a5bdc4d554d29ec9f96dc923e40a6ed (diff)
downloadwix-3f0af880a3d8a41e1a6ac342f8fba06d22b223a0.tar.gz
wix-3f0af880a3d8a41e1a6ac342f8fba06d22b223a0.tar.bz2
wix-3f0af880a3d8a41e1a6ac342f8fba06d22b223a0.zip
Make Feature/@Absent and Feature/@AllowAdvertise consistent
Conversion for wixtoolset/issues#5990
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Converters/WixConverter.cs36
-rw-r--r--src/test/WixToolsetTest.Converters/FeatureFixture.cs77
2 files changed, 113 insertions, 0 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs
index c18b095e..a05c7f58 100644
--- a/src/WixToolset.Converters/WixConverter.cs
+++ b/src/WixToolset.Converters/WixConverter.cs
@@ -481,6 +481,32 @@ namespace WixToolset.Converters
481 481
482 private void ConvertFeatureElement(XElement element) 482 private void ConvertFeatureElement(XElement element)
483 { 483 {
484 var xAbsent = element.Attribute("Absent");
485 if (xAbsent != null &&
486 this.OnError(ConverterTestType.FeatureAbsentAttributeReplaced, element, "The Feature element's Absent attribute has been replaced with the AllowAbsent attribute. Use the 'AllowAbsent' attribute instead."))
487 {
488 if (xAbsent.Value == "allow")
489 {
490 element.Add(new XAttribute("AllowAbsent", "yes"));
491 }
492 xAbsent.Remove();
493 }
494
495 var xAllowAdvertise = element.Attribute("AllowAdvertise");
496 if (xAllowAdvertise != null)
497 {
498 if ((xAllowAdvertise.Value == "system" || xAllowAdvertise.Value == "allow") &&
499 this.OnError(ConverterTestType.FeatureAllowAdvertiseValueDeprecated, element, "The AllowAdvertise attribute's '{0}' value deprecated. Set the value to 'yes' instead.", xAllowAdvertise.Value))
500 {
501 xAllowAdvertise.Value = "yes";
502 }
503 else if (xAllowAdvertise.Value == "disallow" &&
504 this.OnError(ConverterTestType.FeatureAllowAdvertiseValueDeprecated, element, "The AllowAdvertise attribute's '{0}' value deprecated. Remove the value instead.", xAllowAdvertise.Value))
505 {
506 xAllowAdvertise.Remove();
507 }
508 }
509
484 var xCondition = element.Element(ConditionElementName); 510 var xCondition = element.Element(ConditionElementName);
485 if (xCondition != null) 511 if (xCondition != null)
486 { 512 {
@@ -1132,6 +1158,16 @@ namespace WixToolset.Converters
1132 /// Displayed when the XML declaration is present in the source file. 1158 /// Displayed when the XML declaration is present in the source file.
1133 /// </summary> 1159 /// </summary>
1134 DeclarationPresent, 1160 DeclarationPresent,
1161
1162 /// <summary>
1163 /// The Feature Absent attribute renamed to AllowAbsent.
1164 /// </summary>
1165 FeatureAbsentAttributeReplaced,
1166
1167 /// <summary>
1168 /// The Feature AllowAdvertise attribute value deprecated.
1169 /// </summary>
1170 FeatureAllowAdvertiseValueDeprecated,
1135 } 1171 }
1136 } 1172 }
1137} 1173}
diff --git a/src/test/WixToolsetTest.Converters/FeatureFixture.cs b/src/test/WixToolsetTest.Converters/FeatureFixture.cs
new file mode 100644
index 00000000..9d943773
--- /dev/null
+++ b/src/test/WixToolsetTest.Converters/FeatureFixture.cs
@@ -0,0 +1,77 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolsetTest.Converters
4{
5 using System;
6 using System.Xml.Linq;
7 using WixToolset.Converters;
8 using WixToolsetTest.Converters.Mocks;
9 using Xunit;
10
11 public class FeatureFixture : BaseConverterFixture
12 {
13 [Fact]
14 public void FixAllowAttributes()
15 {
16 var parse = String.Join(Environment.NewLine,
17 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
18 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
19 " <Fragment>",
20 " <Feature Absent='allow' AllowAdvertise='system' />",
21 " </Fragment>",
22 "</Wix>");
23
24 var expected = new[]
25 {
26 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
27 " <Fragment>",
28 " <Feature AllowAdvertise=\"yes\" AllowAbsent=\"yes\" />",
29 " </Fragment>",
30 "</Wix>"
31 };
32
33 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
34
35 var messaging = new MockMessaging();
36 var converter = new WixConverter(messaging, 2, null, null);
37
38 var errors = converter.ConvertDocument(document);
39 Assert.Equal(4, errors);
40
41 var actualLines = UnformattedDocumentLines(document);
42 CompareLineByLine(expected, actualLines);
43 }
44
45 [Fact]
46 public void RemoveDeprecatedAllowAdvertiseAttributes()
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 AllowAdvertise='disallow' />",
53 " </Fragment>",
54 "</Wix>");
55
56 var expected = new[]
57 {
58 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
59 " <Fragment>",
60 " <Feature />",
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}