From ecad1128c6223920a035cd12502e316452e61c93 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 19 Jul 2020 19:08:40 +1000 Subject: Set DpiAwareness to "unaware" from v3. --- src/WixToolset.Converters/WixConverter.cs | 18 ++++- .../BootstrapperApplicationFixture.cs | 76 ++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/test/WixToolsetTest.Converters/BootstrapperApplicationFixture.cs (limited to 'src') diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 3ea0c3dc..c9ebdfd3 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs @@ -39,6 +39,7 @@ namespace WixToolset.Converters private static readonly XName AdvertiseExecuteSequenceElementName = WixNamespace + "AdvertiseExecuteSequence"; private static readonly XName InstallExecuteSequenceElementName = WixNamespace + "InstallExecuteSequence"; private static readonly XName InstallUISequenceSequenceElementName = WixNamespace + "InstallUISequence"; + private static readonly XName BootstrapperApplicationElementName = WixNamespace + "BootstrapperApplication"; private static readonly XName EmbeddedChainerElementName = WixNamespace + "EmbeddedChainer"; private static readonly XName ColumnElementName = WixNamespace + "Column"; private static readonly XName ComponentElementName = WixNamespace + "Component"; @@ -130,6 +131,7 @@ namespace WixToolset.Converters { WixConverter.AdvertiseExecuteSequenceElementName, this.ConvertSequenceElement }, { WixConverter.InstallUISequenceSequenceElementName, this.ConvertSequenceElement }, { WixConverter.InstallExecuteSequenceElementName, this.ConvertSequenceElement }, + { WixConverter.BootstrapperApplicationElementName, this.ConvertBootstrapperApplicationElement }, { WixConverter.ColumnElementName, this.ConvertColumnElement }, { WixConverter.CustomTableElementName, this.ConvertCustomTableElement }, { WixConverter.ControlElementName, this.ConvertControlElement }, @@ -442,6 +444,15 @@ namespace WixToolset.Converters } } + private void ConvertBootstrapperApplicationElement(XElement element) + { + if (this.SourceVersion < 4 && null == element.Attribute("DpiAwareness") && + this.OnError(ConverterTestType.AssignBootstrapperApplicationDpiAwareness, element, "The BootstrapperApplication DpiAwareness attribute is being set to 'unaware' to ensure it remains the same as the v3 default")) + { + element.Add(new XAttribute("DpiAwareness", "unaware")); + } + } + private void ConvertColumnElement(XElement element) { var category = element.Attribute("Category"); @@ -1212,7 +1223,12 @@ namespace WixToolset.Converters /// /// The Condition='1' attribute is unnecessary on Publish elements. /// - PublishConditionOneUnnecessary + PublishConditionOneUnnecessary, + + /// + /// DpiAwareness is new and is defaulted to 'perMonitorV2' which is a change in behavior. + /// + AssignBootstrapperApplicationDpiAwareness, } } } diff --git a/src/test/WixToolsetTest.Converters/BootstrapperApplicationFixture.cs b/src/test/WixToolsetTest.Converters/BootstrapperApplicationFixture.cs new file mode 100644 index 00000000..1551077b --- /dev/null +++ b/src/test/WixToolsetTest.Converters/BootstrapperApplicationFixture.cs @@ -0,0 +1,76 @@ +// 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 BootstrapperApplicationFixture : BaseConverterFixture + { + [Fact] + public void SetsDpiUnawareFromV3() + { + 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(2, errors); + + var actualLines = UnformattedDocumentLines(document); + CompareLineByLine(expected, actualLines); + } + + [Fact] + public void DoesntSetDpiUnawareFromV4() + { + 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(0, errors); + + var actualLines = UnformattedDocumentLines(document); + CompareLineByLine(expected, actualLines); + } + } +} -- cgit v1.2.3-55-g6feb