aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-03-19 11:11:58 -0700
committerRob Mensching <rob@firegiant.com>2022-03-19 11:54:45 -0700
commit5390ea994aa575d0b31abd2d577fc6a278c851c6 (patch)
tree577a874d25c06cc5706f28d87f5473b8af43495b
parent3e6d208dc34615d2e6428eb91ce16583eb331f7b (diff)
downloadwix-5390ea994aa575d0b31abd2d577fc6a278c851c6.tar.gz
wix-5390ea994aa575d0b31abd2d577fc6a278c851c6.tar.bz2
wix-5390ea994aa575d0b31abd2d577fc6a278c851c6.zip
Minor code clean up
-rw-r--r--src/api/wix/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs47
-rw-r--r--src/wix/WixToolset.Core/Compiler_Tag.cs3
-rw-r--r--src/wix/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs32
3 files changed, 53 insertions, 29 deletions
diff --git a/src/api/wix/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs b/src/api/wix/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs
index fcc2b1f6..522e3b84 100644
--- a/src/api/wix/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs
+++ b/src/api/wix/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs
@@ -14,7 +14,7 @@ namespace WixToolset.Data.WindowsInstaller
14 { 14 {
15 public const string XmlNamespaceUri = "http://wixtoolset.org/schemas/v4/wi/tables"; 15 public const string XmlNamespaceUri = "http://wixtoolset.org/schemas/v4/wi/tables";
16 16
17 private Dictionary<string, TableDefinition> collection; 17 private readonly Dictionary<string, TableDefinition> collection;
18 18
19 /// <summary> 19 /// <summary>
20 /// Instantiate a new TableDefinitionCollection class. 20 /// Instantiate a new TableDefinitionCollection class.
@@ -74,59 +74,86 @@ namespace WixToolset.Data.WindowsInstaller
74 /// <param name="tableName">Name of table to locate.</param> 74 /// <param name="tableName">Name of table to locate.</param>
75 /// <param name="table">Table definition if found.</param> 75 /// <param name="table">Table definition if found.</param>
76 /// <returns>True if table definition was found otherwise false.</returns> 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 }
78 81
79 /// <summary> 82 /// <summary>
80 /// Adds a table definition to the collection. 83 /// Adds a table definition to the collection.
81 /// </summary> 84 /// </summary>
82 /// <param name="tableDefinition">Table definition to add to the collection.</param> 85 /// <param name="tableDefinition">Table definition to add to the collection.</param>
83 /// <value>Indexes by table definition name.</value> 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 }
85 91
86 /// <summary> 92 /// <summary>
87 /// Removes all table definitions from the collection. 93 /// Removes all table definitions from the collection.
88 /// </summary> 94 /// </summary>
89 public void Clear() => this.collection.Clear(); 95 public void Clear()
96 {
97 this.collection.Clear();
98 }
90 99
91 /// <summary> 100 /// <summary>
92 /// Checks if the collection contains a table name. 101 /// Checks if the collection contains a table name.
93 /// </summary> 102 /// </summary>
94 /// <param name="tableName">The table to check in the collection.</param> 103 /// <param name="tableName">The table to check in the collection.</param>
95 /// <returns>True if collection contains the table.</returns> 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 }
97 109
98 /// <summary> 110 /// <summary>
99 /// Checks if the collection contains a table. 111 /// Checks if the collection contains a table.
100 /// </summary> 112 /// </summary>
101 /// <param name="table">The table to check in the collection.</param> 113 /// <param name="table">The table to check in the collection.</param>
102 /// <returns>True if collection contains the table.</returns> 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 }
104 119
105 /// <summary> 120 /// <summary>
106 /// Copies table definitions to an arry. 121 /// Copies table definitions to an arry.
107 /// </summary> 122 /// </summary>
108 /// <param name="array">Array to copy the table definitions to.</param> 123 /// <param name="array">Array to copy the table definitions to.</param>
109 /// <param name="index">Index in the array to start copying at.</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 }
111 129
112 /// <summary> 130 /// <summary>
113 /// Removes a table definition from the collection. 131 /// Removes a table definition from the collection.
114 /// </summary> 132 /// </summary>
115 /// <param name="table">Table to remove from the collection.</param> 133 /// <param name="table">Table to remove from the collection.</param>
116 /// <returns>True if the table definition existed in the collection and was removed.</returns> 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 }
118 139
119 /// <summary> 140 /// <summary>
120 /// Gets enumerator for the collection. 141 /// Gets enumerator for the collection.
121 /// </summary> 142 /// </summary>
122 /// <returns>Enumerator for the collection.</returns> 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 }
124 148
125 /// <summary> 149 /// <summary>
126 /// Gets the untyped enumerator for the collection. 150 /// Gets the untyped enumerator for the collection.
127 /// </summary> 151 /// </summary>
128 /// <returns>Untyped enumerator for the collection.</returns> 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 }
130 157
131 /// <summary> 158 /// <summary>
132 /// Loads a collection of table definitions from a XmlReader in memory. 159 /// Loads a collection of table definitions from a XmlReader in memory.
diff --git a/src/wix/WixToolset.Core/Compiler_Tag.cs b/src/wix/WixToolset.Core/Compiler_Tag.cs
index 64341808..dfb14c5d 100644
--- a/src/wix/WixToolset.Core/Compiler_Tag.cs
+++ b/src/wix/WixToolset.Core/Compiler_Tag.cs
@@ -6,6 +6,7 @@ namespace WixToolset.Core
6 using System.Xml.Linq; 6 using System.Xml.Linq;
7 using WixToolset.Data; 7 using WixToolset.Data;
8 using WixToolset.Data.Symbols; 8 using WixToolset.Data.Symbols;
9 using WixToolset.Data.WindowsInstaller;
9 10
10 /// <summary> 11 /// <summary>
11 /// Compiler of the WiX toolset. 12 /// Compiler of the WiX toolset.
@@ -248,7 +249,7 @@ namespace WixToolset.Core
248 } 249 }
249 this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, id.Id, true); 250 this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, id.Id, true);
250 251
251 this.Core.EnsureTable(sourceLineNumbers, "SoftwareIdentificationTag"); 252 this.Core.EnsureTable(sourceLineNumbers, WindowsInstallerTableDefinitions.SoftwareIdentificationTag);
252 this.Core.AddSymbol(new WixPackageTagSymbol(sourceLineNumbers, id) 253 this.Core.AddSymbol(new WixPackageTagSymbol(sourceLineNumbers, id)
253 { 254 {
254 FileRef = id.Id, 255 FileRef = id.Id,
diff --git a/src/wix/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs b/src/wix/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs
index a2486130..651cd7e6 100644
--- a/src/wix/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs
+++ b/src/wix/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs
@@ -33,31 +33,27 @@ namespace WixToolset.Core.ExtensibilityServices
33 { 33 {
34 // First, look in the built-ins. 34 // First, look in the built-ins.
35 symbolDefinition = SymbolDefinitions.ByName(name); 35 symbolDefinition = SymbolDefinitions.ByName(name);
36 36 if (symbolDefinition != null)
37 if (symbolDefinition == null)
38 { 37 {
39 if (this.ExtensionData == null) 38 return true;
40 { 39 }
41 this.LoadExtensionData();
42 }
43 40
44 // Second, look in the extensions. 41 if (this.ExtensionData == null)
45 foreach (var data in this.ExtensionData) 42 {
46 { 43 this.LoadExtensionData();
47 if (data.TryGetSymbolDefinitionByName(name, out symbolDefinition)) 44 }
48 {
49 break;
50 }
51 }
52 45
53 // Finally, look in the custom symbol definitions provided during an intermediate load. 46 // Second, look in the extensions.
54 if (symbolDefinition == null) 47 foreach (var data in this.ExtensionData)
48 {
49 if (data.TryGetSymbolDefinitionByName(name, out symbolDefinition))
55 { 50 {
56 this.CustomDefinitionByName.TryGetValue(name, out symbolDefinition); 51 return true;
57 } 52 }
58 } 53 }
59 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);
61 } 57 }
62 58
63 private void LoadExtensionData() 59 private void LoadExtensionData()