Skip to content

Commit

Permalink
Modernize DependencyCompiler and tuples.
Browse files Browse the repository at this point in the history
  • Loading branch information
rseanhall committed Apr 8, 2020
1 parent 40d3860 commit 9524fee
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public void CanBuildUsingProvides()
var results = build.BuildAndQuery(Build, "WixDependencyProvider");
Assert.Equal(new[]
{
"WixDependencyProvider:depJQsOasf1FRUsKxq8THB9sXk8yws\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tUsingProvides\t\t\t0",
}, results.OrderBy(s => s).ToArray());
"WixDependencyProvider:depJQsOasf1FRUsKxq8THB9sXk8yws\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tUsingProvides\t\t\t",
}, results);
}

private static void Build(string[] args)
Expand Down
182 changes: 80 additions & 102 deletions src/wixext/DependencyCompiler.cs

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions src/wixext/DependencyTableDefinitions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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 WixToolset.Dependency
{
using WixToolset.Data;
using WixToolset.Data.WindowsInstaller;

public static class DependencyTableDefinitions
{
public static readonly TableDefinition WixDependencyProvider = new TableDefinition(
"WixDependencyProvider",
new[]
{
new ColumnDefinition("WixDependencyProvider", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column),
new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "The foreign key into the Component table used to determine install state.", modularizeType: ColumnModularizeType.Column),
new ColumnDefinition("ProviderKey", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The name of the registry key that holds the provider identity."),
new ColumnDefinition("Version", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Version, description: "The version of the package."),
new ColumnDefinition("DisplayName", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Text, description: "The display name of the package."),
new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 2147483647, description: "A 32-bit word that specifies the attribute flags to be applied."),
},
tupleDefinitionName: TupleDefinitions.WixDependencyProvider.Name,
tupleIdIsPrimaryKey: true
);

public static readonly TableDefinition WixDependency = new TableDefinition(
"WixDependency",
new[]
{
new ColumnDefinition("WixDependency", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column),
new ColumnDefinition("ProviderKey", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The name of the registry key that holds the provider identity."),
new ColumnDefinition("MinVersion", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Version, description: "The minimum version of the provider supported."),
new ColumnDefinition("MaxVersion", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Version, description: "The maximum version of the provider supported."),
new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 2147483647, description: "A 32-bit word that specifies the attribute flags to be applied."),
},
tupleDefinitionName: DependencyTupleDefinitions.WixDependency.Name,
tupleIdIsPrimaryKey: true
);

public static readonly TableDefinition WixDependencyRef = new TableDefinition(
"WixDependencyRef",
new[]
{
new ColumnDefinition("WixDependencyProvider_", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyTable: "WixDependencyProvider", keyColumn: 1, description: "Foreign key into the Component table.", modularizeType: ColumnModularizeType.Column),
new ColumnDefinition("WixDependency_", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyTable: "WixDependency", keyColumn: 1, description: "Foreign key into the WixDependency table.", modularizeType: ColumnModularizeType.Column),
},
tupleDefinitionName: DependencyTupleDefinitions.WixDependencyRef.Name,
tupleIdIsPrimaryKey: false
);

public static readonly TableDefinition[] All = new[]
{
WixDependencyProvider,
WixDependency,
WixDependencyRef,
};
}
}
18 changes: 2 additions & 16 deletions src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@
namespace WixToolset.Dependency
{
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using WixToolset.Data.WindowsInstaller;
using WixToolset.Extensibility;

public class DependencyWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension
{
private static readonly TableDefinition[] Tables = LoadTables();
public override IEnumerable<TableDefinition> TableDefinitions => DependencyTableDefinitions.All;

public override IEnumerable<TableDefinition> TableDefinitions => Tables;

private static TableDefinition[] LoadTables()
{
using (var resourceStream = typeof(DependencyWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Dependency.tables.xml"))
using (var reader = XmlReader.Create(resourceStream))
{
var tables = TableDefinitionCollection.Load(reader);
return tables.ToArray();
}
}

#if TODO_TAG_BINDER_EXTENSION
#if TODO_DEPENDENCY_BINDER_EXTENSION
private Output output;

/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions src/wixext/Tuples/DependencyTupleDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace WixToolset.Dependency
public enum DependencyTupleDefinitionType
{
WixDependency,
WixDependencyProvider,
WixDependencyRef,
}

Expand All @@ -33,9 +32,6 @@ public static IntermediateTupleDefinition ByType(DependencyTupleDefinitionType t
case DependencyTupleDefinitionType.WixDependency:
return DependencyTupleDefinitions.WixDependency;

case DependencyTupleDefinitionType.WixDependencyProvider:
return DependencyTupleDefinitions.WixDependencyProvider;

case DependencyTupleDefinitionType.WixDependencyRef:
return DependencyTupleDefinitions.WixDependencyRef;

Expand Down
87 changes: 0 additions & 87 deletions src/wixext/Tuples/WixDependencyProviderTuple.cs

This file was deleted.

20 changes: 10 additions & 10 deletions src/wixext/Tuples/WixDependencyRefTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public static partial class DependencyTupleDefinitions
DependencyTupleDefinitionType.WixDependencyRef.ToString(),
new[]
{
new IntermediateFieldDefinition(nameof(WixDependencyRefTupleFields.WixDependencyProvider_), IntermediateFieldType.String),
new IntermediateFieldDefinition(nameof(WixDependencyRefTupleFields.WixDependency_), IntermediateFieldType.String),
new IntermediateFieldDefinition(nameof(WixDependencyRefTupleFields.WixDependencyProviderRef), IntermediateFieldType.String),
new IntermediateFieldDefinition(nameof(WixDependencyRefTupleFields.WixDependencyRef), IntermediateFieldType.String),
},
typeof(WixDependencyRefTuple));
}
Expand All @@ -24,8 +24,8 @@ namespace WixToolset.Dependency.Tuples

public enum WixDependencyRefTupleFields
{
WixDependencyProvider_,
WixDependency_,
WixDependencyProviderRef,
WixDependencyRef,
}

public class WixDependencyRefTuple : IntermediateTuple
Expand All @@ -40,16 +40,16 @@ public WixDependencyRefTuple(SourceLineNumber sourceLineNumber, Identifier id =

public IntermediateField this[WixDependencyRefTupleFields index] => this.Fields[(int)index];

public string WixDependencyProvider_
public string WixDependencyProviderRef
{
get => this.Fields[(int)WixDependencyRefTupleFields.WixDependencyProvider_].AsString();
set => this.Set((int)WixDependencyRefTupleFields.WixDependencyProvider_, value);
get => this.Fields[(int)WixDependencyRefTupleFields.WixDependencyProviderRef].AsString();
set => this.Set((int)WixDependencyRefTupleFields.WixDependencyProviderRef, value);
}

public string WixDependency_
public string WixDependencyRef
{
get => this.Fields[(int)WixDependencyRefTupleFields.WixDependency_].AsString();
set => this.Set((int)WixDependencyRefTupleFields.WixDependency_, value);
get => this.Fields[(int)WixDependencyRefTupleFields.WixDependencyRef].AsString();
set => this.Set((int)WixDependencyRefTupleFields.WixDependencyRef, value);
}
}
}
8 changes: 0 additions & 8 deletions src/wixext/Tuples/WixDependencyTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static partial class DependencyTupleDefinitions
DependencyTupleDefinitionType.WixDependency.ToString(),
new[]
{
new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.WixDependency), IntermediateFieldType.String),
new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.ProviderKey), IntermediateFieldType.String),
new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.MinVersion), IntermediateFieldType.String),
new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.MaxVersion), IntermediateFieldType.String),
Expand All @@ -27,7 +26,6 @@ namespace WixToolset.Dependency.Tuples

public enum WixDependencyTupleFields
{
WixDependency,
ProviderKey,
MinVersion,
MaxVersion,
Expand All @@ -46,12 +44,6 @@ public WixDependencyTuple(SourceLineNumber sourceLineNumber, Identifier id = nul

public IntermediateField this[WixDependencyTupleFields index] => this.Fields[(int)index];

public string WixDependency
{
get => this.Fields[(int)WixDependencyTupleFields.WixDependency].AsString();
set => this.Set((int)WixDependencyTupleFields.WixDependency, value);
}

public string ProviderKey
{
get => this.Fields[(int)WixDependencyTupleFields.ProviderKey].AsString();
Expand Down
1 change: 0 additions & 1 deletion src/wixext/WixToolset.Dependency.wixext.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<ItemGroup>
<Content Include="$(MSBuildThisFileName).targets" />
<Content Include="dependency.xsd" PackagePath="tools" />
<EmbeddedResource Include="tables.xml" />
<EmbeddedResource Include="$(OutputPath)..\dependency.wixlib" />
</ItemGroup>

Expand Down
38 changes: 0 additions & 38 deletions src/wixext/tables.xml

This file was deleted.

0 comments on commit 9524fee

Please sign in to comment.