From b95bf23bb3b69276147a10a43549586aad58713d Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Fri, 17 Jan 2025 22:21:30 +1100 Subject: Raise conversion warning for After and Before attributes, at least on Sequence and SetProperty elements Signed-off-by: Bevan Weiss --- src/wix/WixToolset.Converters/WixConverter.cs | 19 ++++++--- .../WixToolsetTest.Converters/SequenceFixture.cs | 35 ++++++++++++++++ .../SetPropertyFixture.cs | 47 ++++++++++++++++++++++ 3 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs (limited to 'src') diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs index faa77da9..79539f0c 100644 --- a/src/wix/WixToolset.Converters/WixConverter.cs +++ b/src/wix/WixToolset.Converters/WixConverter.cs @@ -211,7 +211,7 @@ namespace WixToolset.Converters { "WixSchedHttpUrlReservationsInstall", "Wix4SchedHttpUrlReservationsInstall_" }, { "ConfigureIIs", "Wix4ConfigureIIs_" }, { "UninstallCertificates", "Wix4UninstallCertificates_" }, - { "InstallCertificates", "Wix4_" }, + { "InstallCertificates", "Wix4InstallCertificates_" }, { "MessageQueuingUninstall", "Wix4MessageQueuingUninstall_" }, { "MessageQueuingInstall", "Wix4_MessageQueuingInstall" }, { "NetFxScheduleNativeImage", "Wix4NetFxScheduleNativeImage_" }, @@ -914,13 +914,18 @@ namespace WixToolset.Converters private void ConvertCustomElement(XElement element) { - var actionId = element.Attribute("Action")?.Value; + var attributes = new string[] { "Action", "After", "Before" }; - if (actionId != null - && CustomActionIdsWithPlatformSuffix.TryGetValue(actionId, out var replacementId)) + foreach (var attribute in attributes) { - this.OnError(ConverterTestType.CustomActionIdsIncludePlatformSuffix, element, - $"Custom action ids have changed in WiX v4 extensions to support platform-specific custom actions. The platform is applied as a suffix: _X86, _X64, _A64 (Arm64). When manually rescheduling custom action '{actionId}', you must use the new custom action id '{replacementId}'. See the conversion FAQ for more information: https://wixtoolset.org/docs/fourthree/faqs/#converting-packages"); + var attributeValue = element.Attribute(attribute)?.Value; + + if (attributeValue != null + && CustomActionIdsWithPlatformSuffix.TryGetValue(attributeValue, out var replacementId)) + { + this.OnError(ConverterTestType.CustomActionIdsIncludePlatformSuffix, element, + $"Custom action ids have changed in WiX v4 extensions to support platform-specific custom actions. The platform is applied as a suffix: _X86, _X64, _A64 (Arm64). When manually rescheduling custom action '{attributeValue}', you must use the new custom action id '{replacementId}'. See the conversion FAQ for more information: https://wixtoolset.org/docs/fourthree/faqs/#converting-packages"); + } } } @@ -1830,6 +1835,7 @@ namespace WixToolset.Converters { foreach (var child in element.Elements()) { + this.ConvertCustomActionElement(child); this.ConvertInnerTextToAttribute(child, "Condition"); } } @@ -1846,6 +1852,7 @@ namespace WixToolset.Converters private void ConvertSetPropertyElement(XElement element) { + this.ConvertCustomElement(element); this.ConvertInnerTextToAttribute(element, "Condition"); } diff --git a/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs b/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs index 9013877a..6ab5fc67 100644 --- a/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs +++ b/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs @@ -45,5 +45,40 @@ namespace WixToolsetTest.Converters var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); } + + [Fact] + public void FixConditionWixCa() + { + var parse = String.Join(Environment.NewLine, + "", + " ", + " ", + " NOT Installed", + " ", + " ", + ""); + + 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); + Assert.Equal(3, errors); + + var actualLines = UnformattedDocumentLines(document); + WixAssert.CompareLineByLine(expected, actualLines); + } } } diff --git a/src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs b/src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs new file mode 100644 index 00000000..8c680ba1 --- /dev/null +++ b/src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs @@ -0,0 +1,47 @@ +// 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.Xml.Linq; + using WixInternal.TestSupport; + using WixToolset.Converters; + using WixToolsetTest.Converters.Mocks; + using Xunit; + + public class SetPropertyFixture : BaseConverterFixture + { + [Fact] + public void FixConditionWixCa() + { + var parse = String.Join(Environment.NewLine, + "", + " ", + " NOT Installed", + " ", + ""); + + 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); + Assert.Equal(3, errors); + + var actualLines = UnformattedDocumentLines(document); + WixAssert.CompareLineByLine(expected, actualLines); + } + } +} -- cgit v1.2.3-55-g6feb