Minor code clean up
Rob Mensching committed
Mar 19, 2022 at 11:11 UTC
5390ea994aa575d0b31abd2d577fc6a278c851c6
3 files changed
+53
-29
src/api/wix/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs
+37
-10
@@ -14,7 +14,7 @@ namespace WixToolset.Data.WindowsInstaller
14
{
15
public const string XmlNamespaceUri = "http://wixtoolset.org/schemas/v4/wi/tables";
16
17
- private Dictionary<string, TableDefinition> collection;
17
+ private readonly Dictionary<string, TableDefinition> collection;
18
19
/// <summary>
20
/// Instantiate a new TableDefinitionCollection class.
@@ -74,59 +74,86 @@ namespace WixToolset.Data.WindowsInstaller
74
/// <param name="tableName">Name of table to locate.</param>
75
/// <param name="table">Table definition if found.</param>
76
/// <returns>True if table definition was found otherwise false.</returns>
77
- public bool TryGet(string tableName, out TableDefinition table) => this.collection.TryGetValue(tableName, out table);
77
+ public bool TryGet(string tableName, out TableDefinition table)
78
+ {
79
+ return this.collection.TryGetValue(tableName, out table);
80
+ }
81
82
/// <summary>
83
/// Adds a table definition to the collection.
84
/// </summary>
85
/// <param name="tableDefinition">Table definition to add to the collection.</param>
86
/// <value>Indexes by table definition name.</value>
84
- public void Add(TableDefinition tableDefinition) => this.collection.Add(tableDefinition.Name, tableDefinition);
87
+ public void Add(TableDefinition tableDefinition)
88
+ {
89
+ this.collection.Add(tableDefinition.Name, tableDefinition);
90
+ }
91
92
/// <summary>
93
/// Removes all table definitions from the collection.
94
/// </summary>
89
- public void Clear() => this.collection.Clear();
95
+ public void Clear()
96
+ {
97
+ this.collection.Clear();
98
+ }
99
100
/// <summary>
101
/// Checks if the collection contains a table name.
102
/// </summary>
103
/// <param name="tableName">The table to check in the collection.</param>
104
/// <returns>True if collection contains the table.</returns>
96
- public bool Contains(string tableName) => this.collection.ContainsKey(tableName);
105
+ public bool Contains(string tableName)
106
+ {
107
+ return this.collection.ContainsKey(tableName);
108
+ }
109
110
/// <summary>
111
/// Checks if the collection contains a table.
112
/// </summary>
113
/// <param name="table">The table to check in the collection.</param>
114
/// <returns>True if collection contains the table.</returns>
103
- public bool Contains(TableDefinition table) => this.collection.ContainsKey(table.Name);
115
+ public bool Contains(TableDefinition table)
116
+ {
117
+ return this.collection.ContainsKey(table.Name);
118
+ }
119
120
/// <summary>
121
/// Copies table definitions to an arry.
122
/// </summary>
123
/// <param name="array">Array to copy the table definitions to.</param>
124
/// <param name="index">Index in the array to start copying at.</param>
110
- public void CopyTo(TableDefinition[] array, int index) => this.collection.Values.CopyTo(array, index);
125
+ public void CopyTo(TableDefinition[] array, int index)
126
+ {
127
+ this.collection.Values.CopyTo(array, index);
128
+ }
129
130
/// <summary>
131
/// Removes a table definition from the collection.
132
/// </summary>
133
/// <param name="table">Table to remove from the collection.</param>
134
/// <returns>True if the table definition existed in the collection and was removed.</returns>
117
- public bool Remove(TableDefinition table) => this.collection.Remove(table.Name);
135
+ public bool Remove(TableDefinition table)
136
+ {
137
+ return this.collection.Remove(table.Name);
138
+ }
139
140
/// <summary>
141
/// Gets enumerator for the collection.
142
/// </summary>
143
/// <returns>Enumerator for the collection.</returns>
123
- public IEnumerator<TableDefinition> GetEnumerator() => this.collection.Values.GetEnumerator();
144
+ public IEnumerator<TableDefinition> GetEnumerator()
145
+ {
146
+ return this.collection.Values.GetEnumerator();
147
+ }
148
149
/// <summary>
150
/// Gets the untyped enumerator for the collection.
151
/// </summary>
152
/// <returns>Untyped enumerator for the collection.</returns>
129
- IEnumerator IEnumerable.GetEnumerator() => this.collection.Values.GetEnumerator();
153
+ IEnumerator IEnumerable.GetEnumerator()
154
+ {
155
+ return this.collection.Values.GetEnumerator();
156
+ }
157
158
/// <summary>
159
/// Loads a collection of table definitions from a XmlReader in memory.
src/wix/WixToolset.Core/Compiler_Tag.cs
+2
-1
@@ -6,6 +6,7 @@ namespace WixToolset.Core
6
using System.Xml.Linq;
7
using WixToolset.Data;
8
using WixToolset.Data.Symbols;
9
+ using WixToolset.Data.WindowsInstaller;
10
11
/// <summary>
12
/// Compiler of the WiX toolset.
@@ -248,7 +249,7 @@ namespace WixToolset.Core
249
}
250
this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, id.Id, true);
251
251
- this.Core.EnsureTable(sourceLineNumbers, "SoftwareIdentificationTag");
252
+ this.Core.EnsureTable(sourceLineNumbers, WindowsInstallerTableDefinitions.SoftwareIdentificationTag);
253
this.Core.AddSymbol(new WixPackageTagSymbol(sourceLineNumbers, id)
254
{
255
FileRef = id.Id,
src/wix/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs
+14
-18
@@ -33,31 +33,27 @@ namespace WixToolset.Core.ExtensibilityServices
33
{
34
// First, look in the built-ins.
35
symbolDefinition = SymbolDefinitions.ByName(name);
36
-
37
- if (symbolDefinition == null)
36
+ if (symbolDefinition != null)
37
{
39
- if (this.ExtensionData == null)
40
- {
41
- this.LoadExtensionData();
42
- }
38
+ return true;
39
+ }
40
44
- // Second, look in the extensions.
45
- foreach (var data in this.ExtensionData)
46
- {
47
- if (data.TryGetSymbolDefinitionByName(name, out symbolDefinition))
48
- {
49
- break;
50
- }
51
- }
41
+ if (this.ExtensionData == null)
42
+ {
43
+ this.LoadExtensionData();
44
+ }
45
53
- // Finally, look in the custom symbol definitions provided during an intermediate load.
54
- if (symbolDefinition == null)
46
+ // Second, look in the extensions.
47
+ foreach (var data in this.ExtensionData)
48
+ {
49
+ if (data.TryGetSymbolDefinitionByName(name, out symbolDefinition))
50
{
56
- this.CustomDefinitionByName.TryGetValue(name, out symbolDefinition);
51
+ return true;
52
}
53
}
54
60
- return symbolDefinition != null;
55
+ // Finally, look in the custom symbol definitions provided during an intermediate load.
56
+ return this.CustomDefinitionByName.TryGetValue(name, out symbolDefinition);
57
}
58
59
private void LoadExtensionData()