Convert RelatedBundle Action to lowercase
Fixes 7356
Rob Mensching committed
Apr 3, 2023 at 22:44 UTC
6670c51b9b5a56ec893c5fa7a3d26dc6fcc2f2be
2 files changed
+81
src/wix/WixToolset.Converters/WixConverter.cs
+20
@@ -115,6 +115,7 @@ namespace WixToolset.Converters
115
private static readonly XName RequiresElementName = WixNamespace + "Requires";
116
private static readonly XName RequiresRefElementName = WixNamespace + "RequiresRef";
117
private static readonly XName MultiStringValueElementName = WixNamespace + "MultiStringValue";
118
+ private static readonly XName RelatedBundleElementName = WixNamespace + "RelatedBundle";
119
private static readonly XName RemotePayloadElementName = WixNamespace + "RemotePayload";
120
private static readonly XName RegistryKeyElementName = WixNamespace + "RegistryKey";
121
private static readonly XName RegistrySearchElementName = WixNamespace + "RegistrySearch";
@@ -313,6 +314,7 @@ namespace WixToolset.Converters
314
{ WixConverter.MultiStringValueElementName, this.ConvertMultiStringValueElement },
315
{ WixConverter.RegistryKeyElementName, this.ConvertRegistryKeyElement },
316
{ WixConverter.RegistrySearchElementName, this.ConvertRegistrySearchElement },
317
+ { WixConverter.RelatedBundleElementName, this.ConvertRelatedBundleElement },
318
{ WixConverter.RemotePayloadElementName, this.ConvertRemotePayloadElement },
319
{ WixConverter.RequiredPrivilegeElementName, this.ConvertRequiredPrivilegeElement },
320
{ WixConverter.CustomActionRefElementName, this.ConvertCustomActionRefElement },
@@ -1713,6 +1715,19 @@ namespace WixToolset.Converters
1715
}
1716
}
1717
1718
+ private void ConvertRelatedBundleElement(XElement element)
1719
+ {
1720
+ var xAction = element.Attribute("Action");
1721
+ var value = xAction?.Value;
1722
+ var lowercaseValue = value?.ToLowerInvariant();
1723
+
1724
+ if (value != lowercaseValue
1725
+ && this.OnInformation(ConverterTestType.RelatedBundleActionLowercase, element, "The RelatedBundle element's Action attribute value must now be all lowercase. The Action='{0}' will be converted to '{1}'", value, lowercaseValue))
1726
+ {
1727
+ xAction.Value = lowercaseValue;
1728
+ }
1729
+ }
1730
+
1731
private void ConvertRemotePayloadElement(XElement element)
1732
{
1733
var xParent = element.Parent;
@@ -3303,6 +3318,11 @@ namespace WixToolset.Converters
3318
/// The Certificate BinaryKey element has been renamed to BinaryRef.
3319
/// </summary>
3320
CertificateBinaryKeyIsNowBinaryRef,
3321
+
3322
+ /// <summary>
3323
+ /// The RelatedBundle element's Action attribute value must now be all lowercase. The Action='{0}' will be converted to '{1}'
3324
+ /// </summary>
3325
+ RelatedBundleActionLowercase,
3326
}
3327
}
3328
}
src/wix/test/WixToolsetTest.Converters/RelatedBundleFixture.cs
new
+61
@@ -0,0 +1,61 @@
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
+
3
+namespace WixToolsetTest.Converters
4
+{
5
+ using System;
6
+ using System.Linq;
7
+ using System.Xml.Linq;
8
+ using WixInternal.TestSupport;
9
+ using WixToolset.Converters;
10
+ using WixToolsetTest.Converters.Mocks;
11
+ using Xunit;
12
+
13
+ public class RelatedBundleFixture : BaseConverterFixture
14
+ {
15
+ [Fact]
16
+ public void CanConvertActionToLowercase()
17
+ {
18
+ var parse = String.Join(Environment.NewLine,
19
+ "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
20
+ " <Fragment>",
21
+ " <RelatedBundle Id='D' Action='Detect' />",
22
+ " <RelatedBundle Id='U' Action='Upgrade' />",
23
+ " <RelatedBundle Id='A' Action='Addon' />",
24
+ " <RelatedBundle Id='P' Action='Patch' />",
25
+ " </Fragment>",
26
+ "</Wix>");
27
+
28
+ var expected = new[]
29
+ {
30
+ "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
31
+ " <Fragment>",
32
+ " <RelatedBundle Id=\"D\" Action=\"detect\" />",
33
+ " <RelatedBundle Id=\"U\" Action=\"upgrade\" />",
34
+ " <RelatedBundle Id=\"A\" Action=\"addon\" />",
35
+ " <RelatedBundle Id=\"P\" Action=\"patch\" />",
36
+ " </Fragment>",
37
+ "</Wix>"
38
+ };
39
+
40
+ var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
41
+
42
+ var messaging = new MockMessaging();
43
+ var converter = new WixConverter(messaging, 2, null, null);
44
+
45
+ var errors = converter.ConvertDocument(document);
46
+
47
+ var actualLines = UnformattedDocumentLines(document);
48
+ WixAssert.CompareLineByLine(expected, actualLines);
49
+
50
+ WixAssert.CompareLineByLine(new[]
51
+ {
52
+ "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Detect' will be converted to 'detect' (RelatedBundleActionLowercase)",
53
+ "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Upgrade' will be converted to 'upgrade' (RelatedBundleActionLowercase)",
54
+ "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Addon' will be converted to 'addon' (RelatedBundleActionLowercase)",
55
+ "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Patch' will be converted to 'patch' (RelatedBundleActionLowercase)",
56
+ }, messaging.Messages.Select(m => m.ToString()).ToArray());
57
+
58
+ Assert.Equal(4, errors);
59
+ }
60
+ }
61
+}