From 2df59141a12979c9869ad2e62d01e9f7432e2f7c Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 6 Apr 2020 09:06:53 +1000 Subject: Modernize SqlCompiler and tuples. --- src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 4 +- src/wixext/SqlCompiler.cs | 142 ++++++++++++--------- src/wixext/SqlTableDefinitions.cs | 82 ++++++++++++ src/wixext/SqlWindowsInstallerBackendExtension.cs | 23 +--- src/wixext/Tuples/SqlDatabaseTuple.cs | 48 +++---- src/wixext/Tuples/SqlFileSpecTuple.cs | 8 -- src/wixext/Tuples/SqlScriptTuple.cs | 48 +++---- src/wixext/Tuples/SqlStringTuple.cs | 38 +++--- src/wixext/WixToolset.Sql.wixext.csproj | 1 - src/wixext/tables.xml | 73 ----------- 10 files changed, 220 insertions(+), 247 deletions(-) create mode 100644 src/wixext/SqlTableDefinitions.cs delete mode 100644 src/wixext/tables.xml diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs index d7fe74e6..7d51c0fb 100644 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs @@ -19,8 +19,8 @@ namespace WixToolsetTest.Sql var results = build.BuildAndQuery(Build, "SqlString"); Assert.Equal(new[] { - "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t0", - }, results.OrderBy(s => s).ToArray()); + "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", + }, results.ToArray()); } private static void Build(string[] args) diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 3fb33993..22b533de 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -7,6 +7,7 @@ namespace WixToolset.Sql using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Sql.Tuples; /// /// The compiler for the WiX Toolset SQL Server Extension. @@ -45,8 +46,8 @@ namespace WixToolset.Sql switch (parentElement.Name.LocalName) { case "Component": - string componentId = context["ComponentId"]; - string directoryId = context["DirectoryId"]; + var componentId = context["ComponentId"]; + var directoryId = context["DirectoryId"]; switch (element.Name.LocalName) { @@ -92,7 +93,7 @@ namespace WixToolset.Sql /// Identifier for parent component. private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; string database = null; @@ -102,7 +103,7 @@ namespace WixToolset.Sql string server = null; string user = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -230,7 +231,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("sdb", componentId, server, database); } if (null == database) @@ -252,11 +253,11 @@ namespace WixToolset.Sql this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); } - foreach (XElement child in element.Elements()) + foreach (var child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); + var childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); switch (child.Name.LocalName) { case "SqlScript": @@ -285,7 +286,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } - fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); + fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); break; case "SqlLogFileSpec": if (null == componentId) @@ -297,7 +298,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } - logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); + logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); break; default: this.ParseHelper.UnexpectedElement(element, child); @@ -313,23 +314,25 @@ namespace WixToolset.Sql if (null != componentId) { // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); } if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlDatabase", id); - row.Set(1, server); - row.Set(2, instance); - row.Set(3, database); - row.Set(4, componentId); - row.Set(5, user); - row.Set(6, fileSpec?.Id); - row.Set(7, logFileSpec?.Id); + var tuple = section.AddTuple(new SqlDatabaseTuple(sourceLineNumbers, id) + { + Server = server, + Instance = instance, + Database = database, + ComponentRef = componentId, + UserRef = user, + FileSpecRef = fileSpec?.Id, + LogFileSpecRef = logFileSpec?.Id, + }); + if (0 != attributes) { - row.Set(8, attributes); + tuple.Attributes = attributes; } } } @@ -341,9 +344,9 @@ namespace WixToolset.Sql /// /// Element to parse. /// Identifier of sql file specification. - private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element) + private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element, string parentId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string fileName = null; string growthSize = null; @@ -351,7 +354,7 @@ namespace WixToolset.Sql string name = null; string size = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -388,7 +391,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("sfs", parentId, name, fileName); } if (null == name) @@ -405,22 +408,25 @@ namespace WixToolset.Sql if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlFileSpec", id); - row.Set(1, name); - row.Set(2, fileName); + var tuple = section.AddTuple(new SqlFileSpecTuple(sourceLineNumbers, id) + { + Name = name, + Filename = fileName, + }); + if (null != size) { - row.Set(3, size); + tuple.Size = size; } if (null != maxSize) { - row.Set(4, maxSize); + tuple.MaxSize = maxSize; } if (null != growthSize) { - row.Set(5, growthSize); + tuple.GrowthSize = growthSize; } } @@ -435,16 +441,16 @@ namespace WixToolset.Sql /// Optional database to execute script against. private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; - bool rollbackAttribute = false; - bool nonRollbackAttribute = false; + var rollbackAttribute = false; + var nonRollbackAttribute = false; string binary = null; - int sequence = CompilerConstants.IntegerNotSet; + var sequence = CompilerConstants.IntegerNotSet; string user = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -455,7 +461,7 @@ namespace WixToolset.Sql break; case "BinaryKey": binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Binary", binary); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Binary, binary); break; case "Sequence": sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); @@ -466,7 +472,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); } sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); @@ -568,7 +574,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("ssc", componentId, binary, sqlDb); } if (null == binary) @@ -589,20 +595,22 @@ namespace WixToolset.Sql this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlScript", id); - row.Set(1, sqlDb); - row.Set(2, componentId); - row.Set(3, binary); - row.Set(4, user); - row.Set(5, attributes); + var tuple = section.AddTuple(new SqlScriptTuple(sourceLineNumbers, id) + { + SqlDbRef = sqlDb, + ComponentRef = componentId, + ScriptBinaryRef = binary, + UserRef = user, + Attributes = attributes, + }); + if (CompilerConstants.IntegerNotSet != sequence) { - row.Set(6, sequence); + tuple.Sequence = sequence; } } } @@ -615,16 +623,16 @@ namespace WixToolset.Sql /// Optional database to execute string against. private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; - bool rollbackAttribute = false; - bool nonRollbackAttribute = false; - int sequence = CompilerConstants.IntegerNotSet; + var rollbackAttribute = false; + var nonRollbackAttribute = false; + var sequence = CompilerConstants.IntegerNotSet; string sql = null; string user = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -727,7 +735,7 @@ namespace WixToolset.Sql } sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); @@ -746,7 +754,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("sst", componentId, sql, sqlDb); } if (null == sql) @@ -767,22 +775,30 @@ namespace WixToolset.Sql this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlString", id); - row.Set(1, sqlDb); - row.Set(2, componentId); - row.Set(3, sql); - row.Set(4, user); - row.Set(5, attributes); + var tuple = section.AddTuple(new SqlStringTuple(sourceLineNumbers, id) + { + SqlDbRef = sqlDb, + ComponentRef = componentId, + SQL = sql, + UserRef = user, + Attributes = attributes, + }); + if (CompilerConstants.IntegerNotSet != sequence) { - row.Set(6, sequence); + tuple.Sequence = sequence; } } } + + private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) + { + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "InstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "UninstallSqlData"); + } } } diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs new file mode 100644 index 00000000..e980aaae --- /dev/null +++ b/src/wixext/SqlTableDefinitions.cs @@ -0,0 +1,82 @@ +// 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.Sql +{ + using WixToolset.Data.WindowsInstaller; + + public static class SqlTableDefinitions + { + public static readonly TableDefinition SqlDatabase = new TableDefinition( + "SqlDatabase", + new[] + { + new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Server", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of server running SQL Server"), + new ColumnDefinition("Instance", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of SQL Server instance"), + new ColumnDefinition("Database", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Primary key, name of database in a SQL Server"), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state ", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), + }, + tupleDefinitionName: "SqlDatabase", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlFileSpec = new TableDefinition( + "SqlFileSpec", + new[] + { + new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Name", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Logical name of filespec", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Filename", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Filename to use (path must exist)", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Size", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Initial size for file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), + }, + tupleDefinitionName: "SqlFileSpec", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlScript = new TableDefinition( + "SqlScript", + new[] + { + new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("ScriptBinary_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Foreign key, Binary stream that contains SQL Script to execute", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), + new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), + }, + tupleDefinitionName: "SqlScript", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlString = new TableDefinition( + "SqlString", + new[] + { + new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the SqlString", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SQL", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "SQL query to execute"), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), + new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), + }, + tupleDefinitionName: "SqlString", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + SqlDatabase, + SqlFileSpec, + SqlScript, + SqlString, + }; + } +} diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs index 83505059..b679e871 100644 --- a/src/wixext/SqlWindowsInstallerBackendExtension.cs +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs @@ -1,32 +1,13 @@ -// 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. +// 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.Sql { using System.Collections.Generic; - using System.Linq; - using System.Xml; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { - public SqlWindowsInstallerBackendBinderExtension() - { - - } - - private static readonly TableDefinition[] Tables = LoadTables(); - - public override IEnumerable TableDefinitions => Tables; - - private static TableDefinition[] LoadTables() - { - using (var resourceStream = typeof(SqlWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Sql.tables.xml")) - using (var reader = XmlReader.Create(resourceStream)) - { - var tables = TableDefinitionCollection.Load(reader); - return tables.ToArray(); - } - } + public override IEnumerable TableDefinitions => SqlTableDefinitions.All; } } diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs index fd107690..1e056212 100644 --- a/src/wixext/Tuples/SqlDatabaseTuple.cs +++ b/src/wixext/Tuples/SqlDatabaseTuple.cs @@ -11,14 +11,13 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlDatabase.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.SqlDb), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Component_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.User_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_Log), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.LogFileSpecRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), }, typeof(SqlDatabaseTuple)); @@ -31,14 +30,13 @@ namespace WixToolset.Sql.Tuples public enum SqlDatabaseTupleFields { - SqlDb, Server, Instance, Database, - Component_, - User_, - FileSpec_, - FileSpec_Log, + ComponentRef, + UserRef, + FileSpecRef, + LogFileSpecRef, Attributes, } @@ -54,12 +52,6 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; - public string SqlDb - { - get => this.Fields[(int)SqlDatabaseTupleFields.SqlDb].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.SqlDb, value); - } - public string Server { get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); @@ -78,28 +70,28 @@ namespace WixToolset.Sql.Tuples set => this.Set((int)SqlDatabaseTupleFields.Database, value); } - public string Component_ + public string ComponentRef { - get => this.Fields[(int)SqlDatabaseTupleFields.Component_].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.Component_, value); + get => this.Fields[(int)SqlDatabaseTupleFields.ComponentRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.ComponentRef, value); } - public string User_ + public string UserRef { - get => this.Fields[(int)SqlDatabaseTupleFields.User_].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.User_, value); + get => this.Fields[(int)SqlDatabaseTupleFields.UserRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.UserRef, value); } - public string FileSpec_ + public string FileSpecRef { - get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.FileSpec_, value); + get => this.Fields[(int)SqlDatabaseTupleFields.FileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.FileSpecRef, value); } - public string FileSpec_Log + public string LogFileSpecRef { - get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_Log].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.FileSpec_Log, value); + get => this.Fields[(int)SqlDatabaseTupleFields.LogFileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.LogFileSpecRef, value); } public int Attributes diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs index 9813ec83..98a3002b 100644 --- a/src/wixext/Tuples/SqlFileSpecTuple.cs +++ b/src/wixext/Tuples/SqlFileSpecTuple.cs @@ -11,7 +11,6 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlFileSpec.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.FileSpec), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), @@ -28,7 +27,6 @@ namespace WixToolset.Sql.Tuples public enum SqlFileSpecTupleFields { - FileSpec, Name, Filename, Size, @@ -48,12 +46,6 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; - public string FileSpec - { - get => this.Fields[(int)SqlFileSpecTupleFields.FileSpec].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.FileSpec, value); - } - public string Name { get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs index b1f95709..de76d49d 100644 --- a/src/wixext/Tuples/SqlScriptTuple.cs +++ b/src/wixext/Tuples/SqlScriptTuple.cs @@ -11,11 +11,10 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlScript.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Script), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDb_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Component_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinary_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinaryRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.UserRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), }, @@ -29,11 +28,10 @@ namespace WixToolset.Sql.Tuples public enum SqlScriptTupleFields { - Script, - SqlDb_, - Component_, - ScriptBinary_, - User_, + SqlDbRef, + ComponentRef, + ScriptBinaryRef, + UserRef, Attributes, Sequence, } @@ -50,34 +48,28 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; - public string Script + public string SqlDbRef { - get => this.Fields[(int)SqlScriptTupleFields.Script].AsString(); - set => this.Set((int)SqlScriptTupleFields.Script, value); + get => this.Fields[(int)SqlScriptTupleFields.SqlDbRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.SqlDbRef, value); } - public string SqlDb_ + public string ComponentRef { - get => this.Fields[(int)SqlScriptTupleFields.SqlDb_].AsString(); - set => this.Set((int)SqlScriptTupleFields.SqlDb_, value); + get => this.Fields[(int)SqlScriptTupleFields.ComponentRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.ComponentRef, value); } - public string Component_ + public string ScriptBinaryRef { - get => this.Fields[(int)SqlScriptTupleFields.Component_].AsString(); - set => this.Set((int)SqlScriptTupleFields.Component_, value); + get => this.Fields[(int)SqlScriptTupleFields.ScriptBinaryRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.ScriptBinaryRef, value); } - public string ScriptBinary_ + public string UserRef { - get => this.Fields[(int)SqlScriptTupleFields.ScriptBinary_].AsString(); - set => this.Set((int)SqlScriptTupleFields.ScriptBinary_, value); - } - - public string User_ - { - get => this.Fields[(int)SqlScriptTupleFields.User_].AsString(); - set => this.Set((int)SqlScriptTupleFields.User_, value); + get => this.Fields[(int)SqlScriptTupleFields.UserRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.UserRef, value); } public int Attributes diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs index d2cba0e0..77882d33 100644 --- a/src/wixext/Tuples/SqlStringTuple.cs +++ b/src/wixext/Tuples/SqlStringTuple.cs @@ -11,11 +11,10 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlString.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.String), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDb_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.ComponentRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.UserRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), }, @@ -29,11 +28,10 @@ namespace WixToolset.Sql.Tuples public enum SqlStringTupleFields { - String, - SqlDb_, - Component_, + SqlDbRef, + ComponentRef, SQL, - User_, + UserRef, Attributes, Sequence, } @@ -50,22 +48,16 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; - public string String + public string SqlDbRef { - get => this.Fields[(int)SqlStringTupleFields.String].AsString(); - set => this.Set((int)SqlStringTupleFields.String, value); + get => this.Fields[(int)SqlStringTupleFields.SqlDbRef].AsString(); + set => this.Set((int)SqlStringTupleFields.SqlDbRef, value); } - public string SqlDb_ + public string ComponentRef { - get => this.Fields[(int)SqlStringTupleFields.SqlDb_].AsString(); - set => this.Set((int)SqlStringTupleFields.SqlDb_, value); - } - - public string Component_ - { - get => this.Fields[(int)SqlStringTupleFields.Component_].AsString(); - set => this.Set((int)SqlStringTupleFields.Component_, value); + get => this.Fields[(int)SqlStringTupleFields.ComponentRef].AsString(); + set => this.Set((int)SqlStringTupleFields.ComponentRef, value); } public string SQL @@ -74,10 +66,10 @@ namespace WixToolset.Sql.Tuples set => this.Set((int)SqlStringTupleFields.SQL, value); } - public string User_ + public string UserRef { - get => this.Fields[(int)SqlStringTupleFields.User_].AsString(); - set => this.Set((int)SqlStringTupleFields.User_, value); + get => this.Fields[(int)SqlStringTupleFields.UserRef].AsString(); + set => this.Set((int)SqlStringTupleFields.UserRef, value); } public int Attributes diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj index 5db8b9d3..73c7a4e5 100644 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ b/src/wixext/WixToolset.Sql.wixext.csproj @@ -14,7 +14,6 @@ - diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml deleted file mode 100644 index a8b6c3a1..00000000 --- a/src/wixext/tables.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-55-g6feb