diff options
author | Rob Mensching <rob@firegiant.com> | 2023-04-03 23:14:37 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2023-04-04 10:03:45 -0700 |
commit | 65c87736724c38bef42700be92db711963310184 (patch) | |
tree | 54f5e1395c220034f95e992131203997894e1202 | |
parent | 6670c51b9b5a56ec893c5fa7a3d26dc6fcc2f2be (diff) | |
download | wix-65c87736724c38bef42700be92db711963310184.tar.gz wix-65c87736724c38bef42700be92db711963310184.tar.bz2 wix-65c87736724c38bef42700be92db711963310184.zip |
Convert bal:Condition inner-text to Condition attribute
Fixes 7357
-rw-r--r-- | src/wix/WixToolset.Converters/WixConverter.cs | 7 | ||||
-rw-r--r-- | src/wix/test/WixToolsetTest.Converters/BalConditionFixture.cs | 53 |
2 files changed, 60 insertions, 0 deletions
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 | |||
134 | private static readonly XName UITextElementName = WixNamespace + "UIText"; | 134 | private static readonly XName UITextElementName = WixNamespace + "UIText"; |
135 | private static readonly XName VariableElementName = WixNamespace + "Variable"; | 135 | private static readonly XName VariableElementName = WixNamespace + "Variable"; |
136 | private static readonly XName VerbElementName = WixNamespace + "Verb"; | 136 | private static readonly XName VerbElementName = WixNamespace + "Verb"; |
137 | private static readonly XName BalConditionElementName = WixBalNamespace + "Condition"; | ||
137 | private static readonly XName BalPrereqLicenseUrlAttributeName = WixBalNamespace + "PrereqLicenseUrl"; | 138 | private static readonly XName BalPrereqLicenseUrlAttributeName = WixBalNamespace + "PrereqLicenseUrl"; |
138 | private static readonly XName BalPrereqPackageAttributeName = WixBalNamespace + "PrereqPackage"; | 139 | private static readonly XName BalPrereqPackageAttributeName = WixBalNamespace + "PrereqPackage"; |
139 | private static readonly XName BalUseUILanguagesName = WixBalNamespace + "UseUILanguages"; | 140 | private static readonly XName BalUseUILanguagesName = WixBalNamespace + "UseUILanguages"; |
@@ -277,6 +278,7 @@ namespace WixToolset.Converters | |||
277 | { WixConverter.AdvertiseExecuteSequenceElementName, this.ConvertSequenceElement }, | 278 | { WixConverter.AdvertiseExecuteSequenceElementName, this.ConvertSequenceElement }, |
278 | { WixConverter.InstallUISequenceSequenceElementName, this.ConvertSequenceElement }, | 279 | { WixConverter.InstallUISequenceSequenceElementName, this.ConvertSequenceElement }, |
279 | { WixConverter.InstallExecuteSequenceElementName, this.ConvertSequenceElement }, | 280 | { WixConverter.InstallExecuteSequenceElementName, this.ConvertSequenceElement }, |
281 | { WixConverter.BalConditionElementName, this.ConvertBalConditionElement }, | ||
280 | { WixConverter.BootstrapperApplicationElementName, this.ConvertBootstrapperApplicationElement }, | 282 | { WixConverter.BootstrapperApplicationElementName, this.ConvertBootstrapperApplicationElement }, |
281 | { WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement }, | 283 | { WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement }, |
282 | { WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement }, | 284 | { WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement }, |
@@ -675,6 +677,11 @@ namespace WixToolset.Converters | |||
675 | } | 677 | } |
676 | } | 678 | } |
677 | 679 | ||
680 | private void ConvertBalConditionElement(XElement element) | ||
681 | { | ||
682 | this.ConvertInnerTextToAttribute(element, "Condition"); | ||
683 | } | ||
684 | |||
678 | private void ConvertBootstrapperApplicationElement(XElement element) | 685 | private void ConvertBootstrapperApplicationElement(XElement element) |
679 | { | 686 | { |
680 | var xUseUILanguages = element.Attribute(BalUseUILanguagesName); | 687 | 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 @@ | |||
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 BalConditionFixture : 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' xmlns:bal='http://schemas.microsoft.com/wix/BalExtension'>", | ||
20 | " <Fragment>", | ||
21 | " <bal:Condition Message='Example message.'>WixBundleInstalled OR NOT (VersionNT = v6.1) OR (VersionNT = v6.1 AND ServicePackLevel = 1)</bal:Condition>", | ||
22 | " </Fragment>", | ||
23 | "</Wix>"); | ||
24 | |||
25 | var expected = new[] | ||
26 | { | ||
27 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:bal=\"http://wixtoolset.org/schemas/v4/wxs/bal\">", | ||
28 | " <Fragment>", | ||
29 | " <bal:Condition Message=\"Example message.\" Condition=\"WixBundleInstalled OR NOT (VersionNT = v6.1) OR (VersionNT = v6.1 AND ServicePackLevel = 1)\" />", | ||
30 | " </Fragment>", | ||
31 | "</Wix>" | ||
32 | }; | ||
33 | |||
34 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
35 | |||
36 | var messaging = new MockMessaging(); | ||
37 | var converter = new WixConverter(messaging, 2, null, null); | ||
38 | |||
39 | var errors = converter.ConvertDocument(document); | ||
40 | |||
41 | var actualLines = UnformattedDocumentLines(document); | ||
42 | WixAssert.CompareLineByLine(expected, actualLines); | ||
43 | |||
44 | WixAssert.CompareLineByLine(new[] | ||
45 | { | ||
46 | "[Converted] The namespace 'http://schemas.microsoft.com/wix/BalExtension' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs/bal'. (XmlnsValueWrong)", | ||
47 | "[Converted] Using Condition element text is deprecated. Use the 'Condition' attribute instead. (InnerTextDeprecated)", | ||
48 | }, messaging.Messages.Select(m => m.ToString()).ToArray()); | ||
49 | |||
50 | Assert.Equal(2, errors); | ||
51 | } | ||
52 | } | ||
53 | } | ||