From 65c87736724c38bef42700be92db711963310184 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 3 Apr 2023 23:14:37 -0700 Subject: Convert bal:Condition inner-text to Condition attribute Fixes 7357 --- src/wix/WixToolset.Converters/WixConverter.cs | 7 +++ .../BalConditionFixture.cs | 53 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/wix/test/WixToolsetTest.Converters/BalConditionFixture.cs diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs index 3b8966cb..109a1eb8 100644 --- a/src/wix/WixToolset.Converters/WixConverter.cs +++ b/src/wix/WixToolset.Converters/WixConverter.cs @@ -134,6 +134,7 @@ namespace WixToolset.Converters private static readonly XName UITextElementName = WixNamespace + "UIText"; private static readonly XName VariableElementName = WixNamespace + "Variable"; private static readonly XName VerbElementName = WixNamespace + "Verb"; + private static readonly XName BalConditionElementName = WixBalNamespace + "Condition"; private static readonly XName BalPrereqLicenseUrlAttributeName = WixBalNamespace + "PrereqLicenseUrl"; private static readonly XName BalPrereqPackageAttributeName = WixBalNamespace + "PrereqPackage"; private static readonly XName BalUseUILanguagesName = WixBalNamespace + "UseUILanguages"; @@ -277,6 +278,7 @@ namespace WixToolset.Converters { WixConverter.AdvertiseExecuteSequenceElementName, this.ConvertSequenceElement }, { WixConverter.InstallUISequenceSequenceElementName, this.ConvertSequenceElement }, { WixConverter.InstallExecuteSequenceElementName, this.ConvertSequenceElement }, + { WixConverter.BalConditionElementName, this.ConvertBalConditionElement }, { WixConverter.BootstrapperApplicationElementName, this.ConvertBootstrapperApplicationElement }, { WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement }, { WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement }, @@ -675,6 +677,11 @@ namespace WixToolset.Converters } } + private void ConvertBalConditionElement(XElement element) + { + this.ConvertInnerTextToAttribute(element, "Condition"); + } + private void ConvertBootstrapperApplicationElement(XElement element) { var xUseUILanguages = element.Attribute(BalUseUILanguagesName); diff --git a/src/wix/test/WixToolsetTest.Converters/BalConditionFixture.cs b/src/wix/test/WixToolsetTest.Converters/BalConditionFixture.cs new file mode 100644 index 00000000..de9e6854 --- /dev/null +++ b/src/wix/test/WixToolsetTest.Converters/BalConditionFixture.cs @@ -0,0 +1,53 @@ +// 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 BalConditionFixture : BaseConverterFixture + { + [Fact] + public void CanConvertActionToLowercase() + { + var parse = String.Join(Environment.NewLine, + "", + " ", + " WixBundleInstalled OR NOT (VersionNT = v6.1) OR (VersionNT = v6.1 AND ServicePackLevel = 1)", + " ", + ""); + + 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 namespace 'http://schemas.microsoft.com/wix/BalExtension' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs/bal'. (XmlnsValueWrong)", + "[Converted] Using Condition element text is deprecated. Use the 'Condition' attribute instead. (InnerTextDeprecated)", + }, messaging.Messages.Select(m => m.ToString()).ToArray()); + + Assert.Equal(2, errors); + } + } +} -- cgit v1.2.3-55-g6feb