From b2ff456469c4905be6df44f851cbf42bbcd629ee Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 27 Dec 2017 13:13:41 -0800 Subject: Make TableDefinitions ColumnDefinitions an array and other minor cleanup --- src/WixToolset.Data/Data/messages.xml | 5 ++++ src/WixToolset.Data/WindowsInstaller/Field.cs | 12 ++------- src/WixToolset.Data/WindowsInstaller/Pdb.cs | 8 ------ src/WixToolset.Data/WindowsInstaller/Row.cs | 2 +- .../WindowsInstaller/TableDefinition.cs | 31 ++++++++++------------ .../WindowsInstaller/TableIndexedCollection.cs | 2 +- 6 files changed, 23 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Data/Data/messages.xml b/src/WixToolset.Data/Data/messages.xml index 3acb21ba..5f03fef5 100644 --- a/src/WixToolset.Data/Data/messages.xml +++ b/src/WixToolset.Data/Data/messages.xml @@ -1,6 +1,11 @@  + diff --git a/src/WixToolset.Data/WindowsInstaller/Field.cs b/src/WixToolset.Data/WindowsInstaller/Field.cs index 11cd2c33..aa359c64 100644 --- a/src/WixToolset.Data/WindowsInstaller/Field.cs +++ b/src/WixToolset.Data/WindowsInstaller/Field.cs @@ -35,16 +35,8 @@ namespace WixToolset.Data.WindowsInstaller /// Data in the field. public object Data { - get - { - return this.data; - } - - set - { - // Validate the value before setting it. - this.data = this.ValidateValue(this.Column, value); - } + get => this.data; + set => this.data = this.ValidateValue(this.Column, value); } /// diff --git a/src/WixToolset.Data/WindowsInstaller/Pdb.cs b/src/WixToolset.Data/WindowsInstaller/Pdb.cs index d3fea0fe..574d5593 100644 --- a/src/WixToolset.Data/WindowsInstaller/Pdb.cs +++ b/src/WixToolset.Data/WindowsInstaller/Pdb.cs @@ -14,14 +14,6 @@ namespace WixToolset.Data.WindowsInstaller public const string XmlNamespaceUri = "http://wixtoolset.org/schemas/v4/wixpdb"; private static readonly Version CurrentVersion = new Version("4.0.0.0"); - /// - /// Creates a new empty pdb object. - /// - /// The source line information for the pdb. - public Pdb() - { - } - /// /// Gets or sets the output that is a part of this pdb. /// diff --git a/src/WixToolset.Data/WindowsInstaller/Row.cs b/src/WixToolset.Data/WindowsInstaller/Row.cs index cb8b81d8..af1af628 100644 --- a/src/WixToolset.Data/WindowsInstaller/Row.cs +++ b/src/WixToolset.Data/WindowsInstaller/Row.cs @@ -37,7 +37,7 @@ namespace WixToolset.Data.WindowsInstaller { this.Number = rowCount++; this.SourceLineNumbers = sourceLineNumbers; - this.Fields = new Field[tableDefinition.Columns.Count]; + this.Fields = new Field[tableDefinition.Columns.Length]; this.TableDefinition = tableDefinition; for (var i = 0; i < this.Fields.Length; ++i) diff --git a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs index 2fb655e5..bc7fb537 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs @@ -25,13 +25,13 @@ namespace WixToolset.Data.WindowsInstaller /// Column definitions for the table. /// Flag if table is unreal. /// Flag if table is part of UX Manifest. - public TableDefinition(string name, IList columns, bool unreal = false, bool bootstrapperApplicationData = false) + public TableDefinition(string name, ColumnDefinition[] columns, bool unreal = false, bool bootstrapperApplicationData = false) { this.Name = name; this.Unreal = unreal; this.BootstrapperApplicationData = bootstrapperApplicationData; - this.Columns = new ReadOnlyCollection(columns); + this.Columns = columns; } /// @@ -56,17 +56,14 @@ namespace WixToolset.Data.WindowsInstaller /// Gets the collection of column definitions for this table. /// /// Collection of column definitions for this table. - public IList Columns { get; private set; } + public ColumnDefinition[] Columns { get; private set; } /// /// Gets the column definition in the table by index. /// /// Index of column to locate. /// Column definition in the table by index. - public ColumnDefinition this[int columnIndex] - { - get { return this.Columns[columnIndex]; } - } + public ColumnDefinition this[int columnIndex] => this.Columns[columnIndex]; /// /// Compares this table definition to another table definition. @@ -91,10 +88,10 @@ namespace WixToolset.Data.WindowsInstaller if (0 == ret) { // transforms can only add columns - ret = Math.Min(0, updated.Columns.Count - this.Columns.Count); + ret = Math.Min(0, updated.Columns.Length - this.Columns.Length); // compare name, type, and length of each column - for (int i = 0; 0 == ret && this.Columns.Count > i; i++) + for (int i = 0; 0 == ret && this.Columns.Length > i; i++) { ColumnDefinition thisColumnDef = this.Columns[i]; ColumnDefinition updatedColumnDef = updated.Columns[i]; @@ -113,10 +110,10 @@ namespace WixToolset.Data.WindowsInstaller /// The TableDefintion represented by the Xml. internal static TableDefinition Read(XmlReader reader) { - bool empty = reader.IsEmptyElement; + var empty = reader.IsEmptyElement; string name = null; - bool unreal = false; - bool bootstrapperApplicationData = false; + var unreal = false; + var bootstrapperApplicationData = false; while (reader.MoveToNextAttribute()) { @@ -139,13 +136,13 @@ namespace WixToolset.Data.WindowsInstaller throw new XmlException(); } - List columns = new List(); - bool hasPrimaryKeyColumn = false; + var columns = new List(); + var hasPrimaryKeyColumn = false; // parse the child elements if (!empty) { - bool done = false; + var done = false; while (!done && reader.Read()) { @@ -155,7 +152,7 @@ namespace WixToolset.Data.WindowsInstaller switch (reader.LocalName) { case "columnDefinition": - ColumnDefinition columnDefinition = ColumnDefinition.Read(reader); + var columnDefinition = ColumnDefinition.Read(reader); columns.Add(columnDefinition); if (columnDefinition.PrimaryKey) @@ -184,7 +181,7 @@ namespace WixToolset.Data.WindowsInstaller } } - return new TableDefinition(name, columns, unreal, bootstrapperApplicationData); + return new TableDefinition(name, columns.ToArray(), unreal, bootstrapperApplicationData); } /// diff --git a/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs b/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs index 1b7de72b..57ba19d1 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs @@ -17,7 +17,7 @@ namespace WixToolset.Data.WindowsInstaller /// public TableIndexedCollection() { - this.collection = new Dictionary(); + this.collection = new Dictionary(); } /// -- cgit v1.2.3-55-g6feb