From e0ef9e78ad5478abb650bbb004f7494f47896b0d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 26 Feb 2021 15:31:39 -0800 Subject: Convert Tag.wixext to SoftwareTag element --- src/WixToolset.Converters/WixConverter.cs | 24 +++++++++++- .../ConverterIntegrationFixture.cs | 8 ++-- .../FirewallExtensionFixture.cs | 2 +- src/test/WixToolsetTest.Converters/TagFixture.cs | 45 ++++++++++++++++++++++ .../Preprocessor/ConvertedPreprocessor.wxs | 4 +- .../TestData/QtExec.bad/v4_expected.wxs | 4 +- .../TestData/QtExec/v4_expected.wxs | 4 +- .../TestData/SingleFile/ConvertedSingleFile.wxs | 4 +- 8 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 src/test/WixToolsetTest.Converters/TagFixture.cs (limited to 'src') diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 4d5564b4..1ba28df3 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs @@ -80,6 +80,8 @@ namespace WixToolset.Converters private static readonly XName SetDirectoryElementName = WixNamespace + "SetDirectory"; private static readonly XName SetPropertyElementName = WixNamespace + "SetProperty"; private static readonly XName ShortcutPropertyElementName = WixNamespace + "ShortcutProperty"; + private static readonly XName SoftwareTagElementName = WixNamespace + "SoftwareTag"; + private static readonly XName TagElementName = XNamespace.None + "Tag"; private static readonly XName TextElementName = WixNamespace + "Text"; private static readonly XName UITextElementName = WixNamespace + "UIText"; private static readonly XName VariableElementName = WixNamespace + "Variable"; @@ -117,7 +119,7 @@ namespace WixToolset.Converters { "http://schemas.microsoft.com/wix/NetFxExtension", "http://wixtoolset.org/schemas/v4/wxs/netfx" }, { "http://schemas.microsoft.com/wix/PSExtension", "http://wixtoolset.org/schemas/v4/wxs/powershell" }, { "http://schemas.microsoft.com/wix/SqlExtension", "http://wixtoolset.org/schemas/v4/wxs/sql" }, - { "http://schemas.microsoft.com/wix/TagExtension", "http://wixtoolset.org/schemas/v4/wxs/tag" }, + { "http://schemas.microsoft.com/wix/TagExtension", XNamespace.None }, { "http://schemas.microsoft.com/wix/UtilExtension", WixUtilNamespace }, { "http://schemas.microsoft.com/wix/VSExtension", "http://wixtoolset.org/schemas/v4/wxs/vs" }, { "http://wixtoolset.org/schemas/thmutil/2010", "http://wixtoolset.org/schemas/v4/thmutil" }, @@ -186,6 +188,7 @@ namespace WixToolset.Converters { WixConverter.SetDirectoryElementName, this.ConvertSetDirectoryElement }, { WixConverter.SetPropertyElementName, this.ConvertSetPropertyElement }, { WixConverter.ShortcutPropertyElementName, this.ConvertShortcutPropertyElement }, + { WixConverter.TagElementName, this.ConvertTagElement }, { WixConverter.TextElementName, this.ConvertTextElement }, { WixConverter.UITextElementName, this.ConvertUITextElement }, { WixConverter.VariableElementName, this.ConvertVariableElement }, @@ -1144,6 +1147,14 @@ namespace WixToolset.Converters } } + private void ConvertTagElement(XElement element) + { + if (this.OnError(ConverterTestType.TagElementRenamed, element, "The Tag element has been renamed. Use the element 'SoftwareTag' name.")) + { + element.Name = SoftwareTagElementName; + } + } + private void ConvertTextElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value"); private void ConvertUITextElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value"); @@ -1378,7 +1389,6 @@ namespace WixToolset.Converters { foreach (var element in elements) { - if (deprecatedToUpdatedNamespaces.TryGetValue(element.Name.Namespace, out var ns)) { element.Name = ns.GetName(element.Name.LocalName); @@ -1396,6 +1406,11 @@ namespace WixToolset.Converters { if (deprecatedToUpdatedNamespaces.TryGetValue(attribute.Value, out ns)) { + if (ns == XNamespace.None) + { + continue; + } + convertedAttribute = ("xmlns" == attribute.Name.LocalName) ? new XAttribute(attribute.Name.LocalName, ns.NamespaceName) : new XAttribute(XNamespace.Xmlns + attribute.Name.LocalName, ns.NamespaceName); } } @@ -1815,6 +1830,11 @@ namespace WixToolset.Converters /// Breaking change: The Win64 attribute's value '{0}' cannot be converted automatically to the new Bitness attribute. /// Win64AttributeRenameCannotBeAutomatic, + + /// + /// The Tag element has been renamed. Use the element 'SoftwareTag' name. + /// + TagElementRenamed, } } } diff --git a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs index 38afca72..cabc89ee 100644 --- a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs +++ b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs @@ -58,7 +58,7 @@ namespace WixToolsetTest.Converters var converter = new WixConverter(messaging, 4); var errors = converter.ConvertFile(targetFile, true); - Assert.Equal(8, errors); + Assert.Equal(9, errors); var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n"); @@ -84,7 +84,7 @@ namespace WixToolsetTest.Converters var settingsFile = Path.Combine(folder, "wixcop.settings.xml"); var result = RunConversion(targetFile, settingsFile: settingsFile); - Assert.Equal(8, result.ExitCode); + Assert.Equal(9, result.ExitCode); var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n"); @@ -108,7 +108,7 @@ namespace WixToolsetTest.Converters File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName)); var result = RunConversion(targetFile); - Assert.Equal(12, result.ExitCode); + Assert.Equal(13, result.ExitCode); var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n"); @@ -133,7 +133,7 @@ namespace WixToolsetTest.Converters var result = RunConversion(targetFile); - Assert.Equal(12, result.ExitCode); + Assert.Equal(13, result.ExitCode); Assert.Single(result.Messages.Where(message => message.ToString().EndsWith("(QtExecCmdTimeoutAmbiguous)"))); var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); diff --git a/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs index f3437078..a101019b 100644 --- a/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs @@ -9,7 +9,7 @@ namespace WixToolsetTest.Converters using WixToolsetTest.Converters.Mocks; using Xunit; - public class ExtensionFixture : BaseConverterFixture + public class FirewallExtensionFixture : BaseConverterFixture { [Fact] public void FixRemoteAddressValue() diff --git a/src/test/WixToolsetTest.Converters/TagFixture.cs b/src/test/WixToolsetTest.Converters/TagFixture.cs new file mode 100644 index 00000000..c163ea11 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/TagFixture.cs @@ -0,0 +1,45 @@ +// 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 WixBuildTools.TestSupport; + using WixToolset.Converters; + using WixToolsetTest.Converters.Mocks; + using Xunit; + + public class TagFixture : BaseConverterFixture + { + [Fact] + public void FixTagExtension() + { + 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); + Assert.Equal(4, errors); + + var actualLines = UnformattedDocumentLines(document); + WixAssert.CompareLineByLine(expected, actualLines); + } + } +} diff --git a/src/test/WixToolsetTest.Converters/TestData/Preprocessor/ConvertedPreprocessor.wxs b/src/test/WixToolsetTest.Converters/TestData/Preprocessor/ConvertedPreprocessor.wxs index b2302b4c..8188d900 100644 --- a/src/test/WixToolsetTest.Converters/TestData/Preprocessor/ConvertedPreprocessor.wxs +++ b/src/test/WixToolsetTest.Converters/TestData/Preprocessor/ConvertedPreprocessor.wxs @@ -4,10 +4,10 @@ - + - + diff --git a/src/test/WixToolsetTest.Converters/TestData/QtExec.bad/v4_expected.wxs b/src/test/WixToolsetTest.Converters/TestData/QtExec.bad/v4_expected.wxs index f26b5d1a..95d2f618 100644 --- a/src/test/WixToolsetTest.Converters/TestData/QtExec.bad/v4_expected.wxs +++ b/src/test/WixToolsetTest.Converters/TestData/QtExec.bad/v4_expected.wxs @@ -4,10 +4,10 @@ - + - + diff --git a/src/test/WixToolsetTest.Converters/TestData/QtExec/v4_expected.wxs b/src/test/WixToolsetTest.Converters/TestData/QtExec/v4_expected.wxs index f5a02e2b..f24d3f8f 100644 --- a/src/test/WixToolsetTest.Converters/TestData/QtExec/v4_expected.wxs +++ b/src/test/WixToolsetTest.Converters/TestData/QtExec/v4_expected.wxs @@ -4,10 +4,10 @@ - + - + diff --git a/src/test/WixToolsetTest.Converters/TestData/SingleFile/ConvertedSingleFile.wxs b/src/test/WixToolsetTest.Converters/TestData/SingleFile/ConvertedSingleFile.wxs index 9a83c237..5bcdaf59 100644 --- a/src/test/WixToolsetTest.Converters/TestData/SingleFile/ConvertedSingleFile.wxs +++ b/src/test/WixToolsetTest.Converters/TestData/SingleFile/ConvertedSingleFile.wxs @@ -4,10 +4,10 @@ - + - + -- cgit v1.2.3-55-g6feb