aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-06-26 14:55:16 -0700
committerRob Mensching <rob@firegiant.com>2020-06-26 14:58:11 -0700
commitf17f7138de534891a2605c9a86c0acc36cc41154 (patch)
tree234c91309630389ad23842b7e3735767a7be48cc /src
parentf0544d8b04951ea0c9ccd03bcdd8284a96bc569c (diff)
downloadwix-f17f7138de534891a2605c9a86c0acc36cc41154.tar.gz
wix-f17f7138de534891a2605c9a86c0acc36cc41154.tar.bz2
wix-f17f7138de534891a2605c9a86c0acc36cc41154.zip
Add inner text conversions for Util.wixext
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Converters/WixConverter.cs8
-rw-r--r--src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs79
2 files changed, 87 insertions, 0 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs
index a89d44ce..89d33598 100644
--- a/src/WixToolset.Converters/WixConverter.cs
+++ b/src/WixToolset.Converters/WixConverter.cs
@@ -63,7 +63,9 @@ namespace WixToolset.Converters
63 private static readonly XName ShortcutPropertyElementName = WixNamespace + "ShortcutProperty"; 63 private static readonly XName ShortcutPropertyElementName = WixNamespace + "ShortcutProperty";
64 private static readonly XName TextElementName = WixNamespace + "Text"; 64 private static readonly XName TextElementName = WixNamespace + "Text";
65 private static readonly XName UITextElementName = WixNamespace + "UIText"; 65 private static readonly XName UITextElementName = WixNamespace + "UIText";
66 private static readonly XName UtilCloseApplicationElementName = WixUtilNamespace + "CloseApplication";
66 private static readonly XName UtilPermissionExElementName = WixUtilNamespace + "PermissionEx"; 67 private static readonly XName UtilPermissionExElementName = WixUtilNamespace + "PermissionEx";
68 private static readonly XName UtilXmlConfigElementName = WixUtilNamespace + "XmlConfig";
67 private static readonly XName CustomActionElementName = WixNamespace + "CustomAction"; 69 private static readonly XName CustomActionElementName = WixNamespace + "CustomAction";
68 private static readonly XName PropertyElementName = WixNamespace + "Property"; 70 private static readonly XName PropertyElementName = WixNamespace + "Property";
69 private static readonly XName WixElementWithoutNamespaceName = XNamespace.None + "Wix"; 71 private static readonly XName WixElementWithoutNamespaceName = XNamespace.None + "Wix";
@@ -156,7 +158,9 @@ namespace WixToolset.Converters
156 { WixConverter.ShortcutPropertyElementName, this.ConvertShortcutPropertyElement }, 158 { WixConverter.ShortcutPropertyElementName, this.ConvertShortcutPropertyElement },
157 { WixConverter.TextElementName, this.ConvertTextElement }, 159 { WixConverter.TextElementName, this.ConvertTextElement },
158 { WixConverter.UITextElementName, this.ConvertUITextElement }, 160 { WixConverter.UITextElementName, this.ConvertUITextElement },
161 { WixConverter.UtilCloseApplicationElementName, this.ConvertUtilCloseApplicationElementName },
159 { WixConverter.UtilPermissionExElementName, this.ConvertUtilPermissionExElement }, 162 { WixConverter.UtilPermissionExElementName, this.ConvertUtilPermissionExElement },
163 { WixConverter.UtilXmlConfigElementName, this.ConvertUtilXmlConfigElement },
160 { WixConverter.PropertyElementName, this.ConvertPropertyElement }, 164 { WixConverter.PropertyElementName, this.ConvertPropertyElement },
161 { WixConverter.WixElementWithoutNamespaceName, this.ConvertElementWithoutNamespace }, 165 { WixConverter.WixElementWithoutNamespaceName, this.ConvertElementWithoutNamespace },
162 { WixConverter.IncludeElementWithoutNamespaceName, this.ConvertElementWithoutNamespace }, 166 { WixConverter.IncludeElementWithoutNamespaceName, this.ConvertElementWithoutNamespace },
@@ -692,6 +696,8 @@ namespace WixToolset.Converters
692 this.ConvertInnerTextToAttribute(xProperty, "Value"); 696 this.ConvertInnerTextToAttribute(xProperty, "Value");
693 } 697 }
694 698
699 private void ConvertUtilCloseApplicationElementName(XElement element) => this.ConvertInnerTextToAttribute(element, "Condition");
700
695 private void ConvertUtilPermissionExElement(XElement element) 701 private void ConvertUtilPermissionExElement(XElement element)
696 { 702 {
697 if (this.SourceVersion < 4 && null == element.Attribute("Inheritable")) 703 if (this.SourceVersion < 4 && null == element.Attribute("Inheritable"))
@@ -707,6 +713,8 @@ namespace WixToolset.Converters
707 } 713 }
708 } 714 }
709 715
716 private void ConvertUtilXmlConfigElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value");
717
710 /// <summary> 718 /// <summary>
711 /// Converts a Wix element. 719 /// Converts a Wix element.
712 /// </summary> 720 /// </summary>
diff --git a/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs b/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs
new file mode 100644
index 00000000..d9c58160
--- /dev/null
+++ b/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs
@@ -0,0 +1,79 @@
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
3namespace WixToolsetTest.Converters
4{
5 using System;
6 using System.Xml.Linq;
7 using WixToolset.Converters;
8 using WixToolsetTest.Converters.Mocks;
9 using Xunit;
10
11 public class UtilExtensionFixture : BaseConverterFixture
12 {
13 [Fact]
14 public void FixCloseAppsCondition()
15 {
16 var parse = String.Join(Environment.NewLine,
17 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>",
18 " <Fragment>",
19 " <util:CloseApplication Id='EndApp' Target='example.exe'>",
20 " a&lt;>b",
21 " </util:CloseApplication>",
22 " </Fragment>",
23 "</Wix>");
24
25 var expected = new[]
26 {
27 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">",
28 " <Fragment>",
29 " <util:CloseApplication Id=\"EndApp\" Target=\"example.exe\" Condition=\"a&lt;&gt;b\" />",
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 Assert.Equal(3, errors);
41
42 var actualLines = UnformattedDocumentLines(document);
43 CompareLineByLine(expected, actualLines);
44 }
45
46 [Fact]
47 public void FixXmlConfigValue()
48 {
49 var parse = String.Join(Environment.NewLine,
50 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>",
51 " <Fragment>",
52 " <util:XmlConfig Id='Change' ElementPath='book'>",
53 " a&lt;>b",
54 " </util:XmlConfig>",
55 " </Fragment>",
56 "</Wix>");
57
58 var expected = new[]
59 {
60 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">",
61 " <Fragment>",
62 " <util:XmlConfig Id=\"Change\" ElementPath=\"book\" Value=\"a&lt;&gt;b\" />",
63 " </Fragment>",
64 "</Wix>"
65 };
66
67 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
68
69 var messaging = new MockMessaging();
70 var converter = new WixConverter(messaging, 2, null, null);
71
72 var errors = converter.ConvertDocument(document);
73 Assert.Equal(3, errors);
74
75 var actualLines = UnformattedDocumentLines(document);
76 CompareLineByLine(expected, actualLines);
77 }
78 }
79}