aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-04-08 14:19:21 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-04-08 14:27:11 +1000
commita10c87c97c270b9c6c923fbb4e61e2fe779d9107 (patch)
tree46a2a7662739838f203c2bb14171529b20508d26
parent7132f1882ebcfeb0113730bd722fa3587bc5e5f4 (diff)
downloadwix-a10c87c97c270b9c6c923fbb4e61e2fe779d9107.tar.gz
wix-a10c87c97c270b9c6c923fbb4e61e2fe779d9107.tar.bz2
wix-a10c87c97c270b9c6c923fbb4e61e2fe779d9107.zip
Modernize DifxAppCompiler and tuples.
-rw-r--r--src/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs10
-rw-r--r--src/wixext/DifxAppCompiler.cs27
-rw-r--r--src/wixext/DifxAppTableDefinitions.cs26
-rw-r--r--src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs18
-rw-r--r--src/wixext/Tuples/MsiDriverPackagesTuple.cs10
-rw-r--r--src/wixext/WixToolset.DifxApp.wixext.csproj1
-rw-r--r--src/wixext/tables.xml14
7 files changed, 53 insertions, 53 deletions
diff --git a/src/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs b/src/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs
index dbe257fa..64acec91 100644
--- a/src/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs
+++ b/src/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs
@@ -19,11 +19,11 @@ namespace WixToolsetTest.DifxApp
19 var results = build.BuildAndQuery(Build, "CustomAction"); 19 var results = build.BuildAndQuery(Build, "CustomAction");
20 Assert.Equal(new[] 20 Assert.Equal(new[]
21 { 21 {
22 "CustomAction:MsiCleanupOnSuccess\t1\tDIFxApp.dll\tCleanupOnSuccess\t0", 22 "CustomAction:MsiCleanupOnSuccess\t1\tDIFxApp.dll\tCleanupOnSuccess\t",
23 "CustomAction:MsiInstallDrivers\t3073\tDIFxAppA.dll\tInstallDriverPackages\t0", 23 "CustomAction:MsiInstallDrivers\t3073\tDIFxAppA.dll\tInstallDriverPackages\t",
24 "CustomAction:MsiProcessDrivers\t1\tDIFxApp.dll\tProcessDriverPackages\t0", 24 "CustomAction:MsiProcessDrivers\t1\tDIFxApp.dll\tProcessDriverPackages\t",
25 "CustomAction:MsiRollbackInstall\t3329\tDIFxAppA.dll\tRollbackInstall\t0", 25 "CustomAction:MsiRollbackInstall\t3329\tDIFxAppA.dll\tRollbackInstall\t",
26 "CustomAction:MsiUninstallDrivers\t3073\tDIFxAppA.dll\tUninstallDriverPackages\t0", 26 "CustomAction:MsiUninstallDrivers\t3073\tDIFxAppA.dll\tUninstallDriverPackages\t",
27 }, results.OrderBy(s => s).ToArray()); 27 }, results.OrderBy(s => s).ToArray());
28 } 28 }
29 29
diff --git a/src/wixext/DifxAppCompiler.cs b/src/wixext/DifxAppCompiler.cs
index 98f36b3f..4d0b8ec9 100644
--- a/src/wixext/DifxAppCompiler.cs
+++ b/src/wixext/DifxAppCompiler.cs
@@ -37,9 +37,9 @@ namespace WixToolset.DifxApp
37 switch (parentElement.Name.LocalName) 37 switch (parentElement.Name.LocalName)
38 { 38 {
39 case "Component": 39 case "Component":
40 string componentId = context["ComponentId"]; 40 var componentId = context["ComponentId"];
41 string directoryId = context["DirectoryId"]; 41 var directoryId = context["DirectoryId"];
42 bool componentWin64 = Boolean.Parse(context["Win64"]); 42 var componentWin64 = Boolean.Parse(context["Win64"]);
43 43
44 switch (element.Name.LocalName) 44 switch (element.Name.LocalName)
45 { 45 {
@@ -64,9 +64,9 @@ namespace WixToolset.DifxApp
64 /// <param name="componentId">Identifier for parent component.</param> 64 /// <param name="componentId">Identifier for parent component.</param>
65 private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64) 65 private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64)
66 { 66 {
67 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); 67 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
68 int attributes = 0; 68 int attributes = 0;
69 int sequence = CompilerConstants.IntegerNotSet; 69 var sequence = CompilerConstants.IntegerNotSet;
70 70
71 // check the number of times a Driver element has been nested under this Component element 71 // check the number of times a Driver element has been nested under this Component element
72 if (null != componentId) 72 if (null != componentId)
@@ -81,7 +81,7 @@ namespace WixToolset.DifxApp
81 } 81 }
82 } 82 }
83 83
84 foreach (XAttribute attrib in node.Attributes()) 84 foreach (var attrib in node.Attributes())
85 { 85 {
86 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) 86 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
87 { 87 {
@@ -138,10 +138,10 @@ namespace WixToolset.DifxApp
138 switch (this.Context.Platform) 138 switch (this.Context.Platform)
139 { 139 {
140 case Platform.X86: 140 case Platform.X86:
141 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MsiProcessDrivers"); 141 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "MsiProcessDrivers");
142 break; 142 break;
143 case Platform.X64: 143 case Platform.X64:
144 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MsiProcessDrivers_x64"); 144 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "MsiProcessDrivers_x64");
145 break; 145 break;
146 case Platform.IA64: 146 case Platform.IA64:
147 case Platform.ARM: 147 case Platform.ARM:
@@ -149,12 +149,15 @@ namespace WixToolset.DifxApp
149 break; 149 break;
150 } 150 }
151 151
152 var row = (MsiDriverPackagesTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "MsiDriverPackages"); 152 var tuple = section.AddTuple(new MsiDriverPackagesTuple(sourceLineNumbers)
153 row.Set(0, componentId); 153 {
154 row.Set(1, attributes); 154 ComponentRef = componentId,
155 Flags = attributes,
156 });
157
155 if (CompilerConstants.IntegerNotSet != sequence) 158 if (CompilerConstants.IntegerNotSet != sequence)
156 { 159 {
157 row.Set(2, sequence); 160 tuple.Sequence = sequence;
158 } 161 }
159 } 162 }
160 } 163 }
diff --git a/src/wixext/DifxAppTableDefinitions.cs b/src/wixext/DifxAppTableDefinitions.cs
new file mode 100644
index 00000000..1ee33196
--- /dev/null
+++ b/src/wixext/DifxAppTableDefinitions.cs
@@ -0,0 +1,26 @@
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 WixToolset.DifxApp
4{
5 using WixToolset.Data.WindowsInstaller;
6
7 public static class DifxAppTableDefinitions
8 {
9 public static readonly TableDefinition MsiDriverPackages = new TableDefinition(
10 "MsiDriverPackages",
11 new[]
12 {
13 new ColumnDefinition("Component", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Name of the component that represents the driver package", modularizeType: ColumnModularizeType.Column),
14 new ColumnDefinition("Flags", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 31, description: "Flags for installing and uninstalling driver packages"),
15 new ColumnDefinition("Sequence", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, description: "Order in which the driver packages are processed"),
16 },
17 tupleDefinitionName: DifxAppTupleDefinitions.MsiDriverPackages.Name,
18 tupleIdIsPrimaryKey: false
19 );
20
21 public static readonly TableDefinition[] All = new[]
22 {
23 MsiDriverPackages,
24 };
25 }
26}
diff --git a/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs b/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs
index c87a661b..d3bbc0eb 100644
--- a/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs
+++ b/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs
@@ -1,27 +1,13 @@
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. 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 2
3namespace WixToolset.DifxApp 3namespace WixToolset.DifxApp
4{ 4{
5 using System.Collections.Generic; 5 using System.Collections.Generic;
6 using System.Linq;
7 using System.Xml;
8 using WixToolset.Data.WindowsInstaller; 6 using WixToolset.Data.WindowsInstaller;
9 using WixToolset.Extensibility; 7 using WixToolset.Extensibility;
10 8
11 public class DifxAppWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension 9 public class DifxAppWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension
12 { 10 {
13 private static readonly TableDefinition[] Tables = LoadTables(); 11 public override IEnumerable<TableDefinition> TableDefinitions => DifxAppTableDefinitions.All;
14
15 public override IEnumerable<TableDefinition> TableDefinitions => Tables;
16
17 private static TableDefinition[] LoadTables()
18 {
19 using (var resourceStream = typeof(DifxAppWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.DifxApp.tables.xml"))
20 using (var reader = XmlReader.Create(resourceStream))
21 {
22 var tables = TableDefinitionCollection.Load(reader);
23 return tables.ToArray();
24 }
25 }
26 } 12 }
27} 13}
diff --git a/src/wixext/Tuples/MsiDriverPackagesTuple.cs b/src/wixext/Tuples/MsiDriverPackagesTuple.cs
index aecc7e77..a1063972 100644
--- a/src/wixext/Tuples/MsiDriverPackagesTuple.cs
+++ b/src/wixext/Tuples/MsiDriverPackagesTuple.cs
@@ -11,7 +11,7 @@ namespace WixToolset.DifxApp
11 DifxAppTupleDefinitionType.MsiDriverPackages.ToString(), 11 DifxAppTupleDefinitionType.MsiDriverPackages.ToString(),
12 new[] 12 new[]
13 { 13 {
14 new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Component), IntermediateFieldType.String), 14 new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.ComponentRef), IntermediateFieldType.String),
15 new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Flags), IntermediateFieldType.Number), 15 new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Flags), IntermediateFieldType.Number),
16 new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Sequence), IntermediateFieldType.Number), 16 new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Sequence), IntermediateFieldType.Number),
17 }, 17 },
@@ -25,7 +25,7 @@ namespace WixToolset.DifxApp.Tuples
25 25
26 public enum MsiDriverPackagesTupleFields 26 public enum MsiDriverPackagesTupleFields
27 { 27 {
28 Component, 28 ComponentRef,
29 Flags, 29 Flags,
30 Sequence, 30 Sequence,
31 } 31 }
@@ -42,10 +42,10 @@ namespace WixToolset.DifxApp.Tuples
42 42
43 public IntermediateField this[MsiDriverPackagesTupleFields index] => this.Fields[(int)index]; 43 public IntermediateField this[MsiDriverPackagesTupleFields index] => this.Fields[(int)index];
44 44
45 public string Component 45 public string ComponentRef
46 { 46 {
47 get => this.Fields[(int)MsiDriverPackagesTupleFields.Component].AsString(); 47 get => this.Fields[(int)MsiDriverPackagesTupleFields.ComponentRef].AsString();
48 set => this.Set((int)MsiDriverPackagesTupleFields.Component, value); 48 set => this.Set((int)MsiDriverPackagesTupleFields.ComponentRef, value);
49 } 49 }
50 50
51 public int Flags 51 public int Flags
diff --git a/src/wixext/WixToolset.DifxApp.wixext.csproj b/src/wixext/WixToolset.DifxApp.wixext.csproj
index 5717b42a..ca27b04e 100644
--- a/src/wixext/WixToolset.DifxApp.wixext.csproj
+++ b/src/wixext/WixToolset.DifxApp.wixext.csproj
@@ -13,7 +13,6 @@
13 <ItemGroup> 13 <ItemGroup>
14 <Content Include="$(MSBuildThisFileName).targets" /> 14 <Content Include="$(MSBuildThisFileName).targets" />
15 <Content Include="difxapp.xsd" PackagePath="tools" /> 15 <Content Include="difxapp.xsd" PackagePath="tools" />
16 <EmbeddedResource Include="tables.xml" />
17 <EmbeddedResource Include="$(OutputPath)..\difxapp.wixlib" /> 16 <EmbeddedResource Include="$(OutputPath)..\difxapp.wixlib" />
18 </ItemGroup> 17 </ItemGroup>
19 <ItemGroup> 18 <ItemGroup>
diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml
deleted file mode 100644
index c328f875..00000000
--- a/src/wixext/tables.xml
+++ /dev/null
@@ -1,14 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4
5<tableDefinitions xmlns="http://wixtoolset.org/schemas/v4/wi/tables">
6 <tableDefinition name="MsiDriverPackages">
7 <columnDefinition name="Component" type="string" length="72" primaryKey="yes" modularize="column"
8 keyTable="Component" keyColumn="1" category="identifier" description="Name of the component that represents the driver package"/>
9 <columnDefinition name="Flags" type="number" length="4"
10 minValue="0" maxValue="31" description="Flags for installing and uninstalling driver packages"/>
11 <columnDefinition name="Sequence" type="number" length="4" nullable="yes"
12 minValue="0" description="Order in which the driver packages are processed"/>
13 </tableDefinition>
14</tableDefinitions>