From 6670c51b9b5a56ec893c5fa7a3d26dc6fcc2f2be Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 3 Apr 2023 22:44:18 -0700 Subject: Convert RelatedBundle Action to lowercase Fixes 7356 --- src/wix/WixToolset.Converters/WixConverter.cs | 20 +++++++ .../RelatedBundleFixture.cs | 61 ++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/wix/test/WixToolsetTest.Converters/RelatedBundleFixture.cs diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs index 2f00d15d..3b8966cb 100644 --- a/src/wix/WixToolset.Converters/WixConverter.cs +++ b/src/wix/WixToolset.Converters/WixConverter.cs @@ -115,6 +115,7 @@ namespace WixToolset.Converters private static readonly XName RequiresElementName = WixNamespace + "Requires"; private static readonly XName RequiresRefElementName = WixNamespace + "RequiresRef"; private static readonly XName MultiStringValueElementName = WixNamespace + "MultiStringValue"; + private static readonly XName RelatedBundleElementName = WixNamespace + "RelatedBundle"; private static readonly XName RemotePayloadElementName = WixNamespace + "RemotePayload"; private static readonly XName RegistryKeyElementName = WixNamespace + "RegistryKey"; private static readonly XName RegistrySearchElementName = WixNamespace + "RegistrySearch"; @@ -313,6 +314,7 @@ namespace WixToolset.Converters { WixConverter.MultiStringValueElementName, this.ConvertMultiStringValueElement }, { WixConverter.RegistryKeyElementName, this.ConvertRegistryKeyElement }, { WixConverter.RegistrySearchElementName, this.ConvertRegistrySearchElement }, + { WixConverter.RelatedBundleElementName, this.ConvertRelatedBundleElement }, { WixConverter.RemotePayloadElementName, this.ConvertRemotePayloadElement }, { WixConverter.RequiredPrivilegeElementName, this.ConvertRequiredPrivilegeElement }, { WixConverter.CustomActionRefElementName, this.ConvertCustomActionRefElement }, @@ -1713,6 +1715,19 @@ namespace WixToolset.Converters } } + private void ConvertRelatedBundleElement(XElement element) + { + var xAction = element.Attribute("Action"); + var value = xAction?.Value; + var lowercaseValue = value?.ToLowerInvariant(); + + if (value != lowercaseValue + && 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)) + { + xAction.Value = lowercaseValue; + } + } + private void ConvertRemotePayloadElement(XElement element) { var xParent = element.Parent; @@ -3303,6 +3318,11 @@ namespace WixToolset.Converters /// The Certificate BinaryKey element has been renamed to BinaryRef. /// CertificateBinaryKeyIsNowBinaryRef, + + /// + /// The RelatedBundle element's Action attribute value must now be all lowercase. The Action='{0}' will be converted to '{1}' + /// + RelatedBundleActionLowercase, } } } diff --git a/src/wix/test/WixToolsetTest.Converters/RelatedBundleFixture.cs b/src/wix/test/WixToolsetTest.Converters/RelatedBundleFixture.cs new file mode 100644 index 00000000..ea0be80b --- /dev/null +++ b/src/wix/test/WixToolsetTest.Converters/RelatedBundleFixture.cs @@ -0,0 +1,61 @@ +// 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. + +namespace WixToolsetTest.Converters +{ + using System; + using System.Linq; + using System.Xml.Linq; + using WixInternal.TestSupport; + using WixToolset.Converters; + using WixToolsetTest.Converters.Mocks; + using Xunit; + + public class RelatedBundleFixture : BaseConverterFixture + { + [Fact] + public void CanConvertActionToLowercase() + { + var parse = String.Join(Environment.NewLine, + "", + " ", + " ", + " ", + " ", + " ", + " ", + ""); + + var expected = new[] + { + "", + " ", + " ", + " ", + " ", + " ", + " ", + "" + }; + + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); + + var messaging = new MockMessaging(); + var converter = new WixConverter(messaging, 2, null, null); + + var errors = converter.ConvertDocument(document); + + var actualLines = UnformattedDocumentLines(document); + WixAssert.CompareLineByLine(expected, actualLines); + + WixAssert.CompareLineByLine(new[] + { + "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Detect' will be converted to 'detect' (RelatedBundleActionLowercase)", + "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Upgrade' will be converted to 'upgrade' (RelatedBundleActionLowercase)", + "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Addon' will be converted to 'addon' (RelatedBundleActionLowercase)", + "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Patch' will be converted to 'patch' (RelatedBundleActionLowercase)", + }, messaging.Messages.Select(m => m.ToString()).ToArray()); + + Assert.Equal(4, errors); + } + } +} -- cgit v1.2.3-55-g6feb