Make TableDefinitions ColumnDefinitions an array and other minor cleanup
Rob Mensching committed
Dec 27, 2017 at 13:13 UTC
b2ff456469c4905be6df44f851cbf42bbcd629ee
6 files changed
+23
-37
src/WixToolset.Data/Data/messages.xml
+5
@@ -1,6 +1,11 @@
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
+
6
+This file has been kept for easy reference until we are certain we don't want to localize error strings.
7
+
8
+-->
9
10
<Messages Namespace="WixToolset" Resources="Data.Messages" xmlns="http://schemas.microsoft.com/genmsgs/2004/07/messages">
11
<Class Name="WixErrors" ContainerName="WixErrorEventArgs" BaseContainerName="MessageEventArgs" Level="Error">
src/WixToolset.Data/WindowsInstaller/Field.cs
+2
-10
@@ -35,16 +35,8 @@ namespace WixToolset.Data.WindowsInstaller
35
/// <value>Data in the field.</value>
36
public object Data
37
{
38
- get
39
- {
40
- return this.data;
41
- }
42
-
43
- set
44
- {
45
- // Validate the value before setting it.
46
- this.data = this.ValidateValue(this.Column, value);
47
- }
38
+ get => this.data;
39
+ set => this.data = this.ValidateValue(this.Column, value);
40
}
41
42
/// <summary>
src/WixToolset.Data/WindowsInstaller/Pdb.cs
-8
@@ -14,14 +14,6 @@ namespace WixToolset.Data.WindowsInstaller
14
public const string XmlNamespaceUri = "http://wixtoolset.org/schemas/v4/wixpdb";
15
private static readonly Version CurrentVersion = new Version("4.0.0.0");
16
17
- /// <summary>
18
- /// Creates a new empty pdb object.
19
- /// </summary>
20
- /// <param name="sourceLineNumbers">The source line information for the pdb.</param>
21
- public Pdb()
22
- {
23
- }
24
-
17
/// <summary>
18
/// Gets or sets the output that is a part of this pdb.
19
/// </summary>
src/WixToolset.Data/WindowsInstaller/Row.cs
+1
-1
@@ -37,7 +37,7 @@ namespace WixToolset.Data.WindowsInstaller
37
{
38
this.Number = rowCount++;
39
this.SourceLineNumbers = sourceLineNumbers;
40
- this.Fields = new Field[tableDefinition.Columns.Count];
40
+ this.Fields = new Field[tableDefinition.Columns.Length];
41
this.TableDefinition = tableDefinition;
42
43
for (var i = 0; i < this.Fields.Length; ++i)
src/WixToolset.Data/WindowsInstaller/TableDefinition.cs
+14
-17
@@ -25,13 +25,13 @@ namespace WixToolset.Data.WindowsInstaller
25
/// <param name="columns">Column definitions for the table.</param>
26
/// <param name="unreal">Flag if table is unreal.</param>
27
/// <param name="bootstrapperApplicationData">Flag if table is part of UX Manifest.</param>
28
- public TableDefinition(string name, IList<ColumnDefinition> columns, bool unreal = false, bool bootstrapperApplicationData = false)
28
+ public TableDefinition(string name, ColumnDefinition[] columns, bool unreal = false, bool bootstrapperApplicationData = false)
29
{
30
this.Name = name;
31
this.Unreal = unreal;
32
this.BootstrapperApplicationData = bootstrapperApplicationData;
33
34
- this.Columns = new ReadOnlyCollection<ColumnDefinition>(columns);
34
+ this.Columns = columns;
35
}
36
37
/// <summary>
@@ -56,17 +56,14 @@ namespace WixToolset.Data.WindowsInstaller
56
/// Gets the collection of column definitions for this table.
57
/// </summary>
58
/// <value>Collection of column definitions for this table.</value>
59
- public IList<ColumnDefinition> Columns { get; private set; }
59
+ public ColumnDefinition[] Columns { get; private set; }
60
61
/// <summary>
62
/// Gets the column definition in the table by index.
63
/// </summary>
64
/// <param name="columnIndex">Index of column to locate.</param>
65
/// <value>Column definition in the table by index.</value>
66
- public ColumnDefinition this[int columnIndex]
67
- {
68
- get { return this.Columns[columnIndex]; }
69
- }
66
+ public ColumnDefinition this[int columnIndex] => this.Columns[columnIndex];
67
68
/// <summary>
69
/// Compares this table definition to another table definition.
@@ -91,10 +88,10 @@ namespace WixToolset.Data.WindowsInstaller
88
if (0 == ret)
89
{
90
// transforms can only add columns
94
- ret = Math.Min(0, updated.Columns.Count - this.Columns.Count);
91
+ ret = Math.Min(0, updated.Columns.Length - this.Columns.Length);
92
93
// compare name, type, and length of each column
97
- for (int i = 0; 0 == ret && this.Columns.Count > i; i++)
94
+ for (int i = 0; 0 == ret && this.Columns.Length > i; i++)
95
{
96
ColumnDefinition thisColumnDef = this.Columns[i];
97
ColumnDefinition updatedColumnDef = updated.Columns[i];
@@ -113,10 +110,10 @@ namespace WixToolset.Data.WindowsInstaller
110
/// <returns>The TableDefintion represented by the Xml.</returns>
111
internal static TableDefinition Read(XmlReader reader)
112
{
116
- bool empty = reader.IsEmptyElement;
113
+ var empty = reader.IsEmptyElement;
114
string name = null;
118
- bool unreal = false;
119
- bool bootstrapperApplicationData = false;
115
+ var unreal = false;
116
+ var bootstrapperApplicationData = false;
117
118
while (reader.MoveToNextAttribute())
119
{
@@ -139,13 +136,13 @@ namespace WixToolset.Data.WindowsInstaller
136
throw new XmlException();
137
}
138
142
- List<ColumnDefinition> columns = new List<ColumnDefinition>();
143
- bool hasPrimaryKeyColumn = false;
139
+ var columns = new List<ColumnDefinition>();
140
+ var hasPrimaryKeyColumn = false;
141
142
// parse the child elements
143
if (!empty)
144
{
148
- bool done = false;
145
+ var done = false;
146
147
while (!done && reader.Read())
148
{
@@ -155,7 +152,7 @@ namespace WixToolset.Data.WindowsInstaller
152
switch (reader.LocalName)
153
{
154
case "columnDefinition":
158
- ColumnDefinition columnDefinition = ColumnDefinition.Read(reader);
155
+ var columnDefinition = ColumnDefinition.Read(reader);
156
columns.Add(columnDefinition);
157
158
if (columnDefinition.PrimaryKey)
@@ -184,7 +181,7 @@ namespace WixToolset.Data.WindowsInstaller
181
}
182
}
183
187
- return new TableDefinition(name, columns, unreal, bootstrapperApplicationData);
184
+ return new TableDefinition(name, columns.ToArray(), unreal, bootstrapperApplicationData);
185
}
186
187
/// <summary>
src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs
+1
-1
@@ -17,7 +17,7 @@ namespace WixToolset.Data.WindowsInstaller
17
/// </summary>
18
public TableIndexedCollection()
19
{
20
- this.collection = new Dictionary<string,Table>();
20
+ this.collection = new Dictionary<string, Table>();
21
}
22
23
/// <summary>