Convert bal:Condition inner-text to Condition attribute
Fixes 7357
Rob Mensching committed
Apr 3, 2023 at 23:14 UTC
65c87736724c38bef42700be92db711963310184
2 files changed
+60
src/wix/WixToolset.Converters/WixConverter.cs
+7
@@ -134,6 +134,7 @@ namespace WixToolset.Converters
134
private static readonly XName UITextElementName = WixNamespace + "UIText";
135
private static readonly XName VariableElementName = WixNamespace + "Variable";
136
private static readonly XName VerbElementName = WixNamespace + "Verb";
137
+ private static readonly XName BalConditionElementName = WixBalNamespace + "Condition";
138
private static readonly XName BalPrereqLicenseUrlAttributeName = WixBalNamespace + "PrereqLicenseUrl";
139
private static readonly XName BalPrereqPackageAttributeName = WixBalNamespace + "PrereqPackage";
140
private static readonly XName BalUseUILanguagesName = WixBalNamespace + "UseUILanguages";
@@ -277,6 +278,7 @@ namespace WixToolset.Converters
278
{ WixConverter.AdvertiseExecuteSequenceElementName, this.ConvertSequenceElement },
279
{ WixConverter.InstallUISequenceSequenceElementName, this.ConvertSequenceElement },
280
{ WixConverter.InstallExecuteSequenceElementName, this.ConvertSequenceElement },
281
+ { WixConverter.BalConditionElementName, this.ConvertBalConditionElement },
282
{ WixConverter.BootstrapperApplicationElementName, this.ConvertBootstrapperApplicationElement },
283
{ WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement },
284
{ WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement },
@@ -675,6 +677,11 @@ namespace WixToolset.Converters
677
}
678
}
679
680
+ private void ConvertBalConditionElement(XElement element)
681
+ {
682
+ this.ConvertInnerTextToAttribute(element, "Condition");
683
+ }
684
+
685
private void ConvertBootstrapperApplicationElement(XElement element)
686
{
687
var xUseUILanguages = element.Attribute(BalUseUILanguagesName);
src/wix/test/WixToolsetTest.Converters/BalConditionFixture.cs
new
+53
@@ -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
+}