From 61cd9e6baeffa365ea535b09d3cf69731b989a9a Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 13 Oct 2020 18:59:30 -0400 Subject: Fix conversion of Product/@Condition. --- src/WixToolset.Converters/WixConverter.cs | 6 ++-- .../WixToolsetTest.Converters/ConditionFixture.cs | 38 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index b82c4490..1fcaacb4 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs @@ -680,10 +680,10 @@ namespace WixToolset.Converters } } - var xCondition = element.Element(ConditionElementName); - if (xCondition != null) + var xConditions = element.Elements(ConditionElementName).ToList(); + foreach (var xCondition in xConditions) { - var message = element.Attribute("Message")?.Value; + var message = xCondition.Attribute("Message")?.Value; if (!String.IsNullOrEmpty(message) && TryGetInnerText(xCondition, out var text) && diff --git a/src/test/WixToolsetTest.Converters/ConditionFixture.cs b/src/test/WixToolsetTest.Converters/ConditionFixture.cs index 65fa6734..629fbd2a 100644 --- a/src/test/WixToolsetTest.Converters/ConditionFixture.cs +++ b/src/test/WixToolsetTest.Converters/ConditionFixture.cs @@ -213,6 +213,44 @@ namespace WixToolsetTest.Converters WixAssert.CompareLineByLine(expected, actualLines); } + [Fact] + public void FixLaunchConditionInProduct() + { + var parse = String.Join(Environment.NewLine, + "", + "", + " ", + " ", + " 1<2", + " ", + " ", + " 1=2", + " ", + " ", + ""); + + 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); + } + [Fact] public void FixPermissionExCondition() { -- cgit v1.2.3-55-g6feb