Make uses of EnsureTable more typesafe
And more removal of row for tuple
Rob Mensching committed
May 23, 2019 at 22:46 UTC
7eb811f1674f210564179254807c7ad9d62b5eab
1 file changed
+22
-20
src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+22
-20
@@ -88,7 +88,7 @@ namespace WixToolset.Core.ExtensibilityServices
88
}
89
90
// For anonymous directories, create the identifier. If this identifier already exists in the
91
- // active section, bail so we don't add duplicate anonymous directory rows (which are legal
91
+ // active section, bail so we don't add duplicate anonymous directory tuples (which are legal
92
// but bloat the intermediate and ultimately make the linker do "busy work").
93
if (null == id)
94
{
@@ -126,9 +126,9 @@ namespace WixToolset.Core.ExtensibilityServices
126
if (1 == inlineSyntax.Length)
127
{
128
id = inlineSyntax[0];
129
- this.CreateSimpleReference(section, sourceLineNumbers, "Directory", id);
129
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.Directory), id);
130
}
131
- else // start creating rows for the entries in the inline syntax
131
+ else // start creating tuples for the entries in the inline syntax
132
{
133
id = parentId;
134
@@ -142,7 +142,7 @@ namespace WixToolset.Core.ExtensibilityServices
142
//}
143
144
id = inlineSyntax[0].TrimEnd(':');
145
- this.CreateSimpleReference(section, sourceLineNumbers, "Directory", id);
145
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.Directory), id);
146
147
pathStartsAt = 1;
148
}
@@ -284,14 +284,14 @@ namespace WixToolset.Core.ExtensibilityServices
284
throw new ArgumentException(nameof(tableName));
285
}
286
287
- return CreateRow(section, sourceLineNumbers, tupleDefinition, identifier);
287
+ return CreateTuple(section, sourceLineNumbers, tupleDefinition, identifier);
288
}
289
290
public IntermediateTuple CreateTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null)
291
{
292
var tupleDefinition = TupleDefinitions.ByType(tupleType);
293
294
- return CreateRow(section, sourceLineNumbers, tupleDefinition, identifier);
294
+ return CreateTuple(section, sourceLineNumbers, tupleDefinition, identifier);
295
}
296
297
public string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args)
@@ -346,8 +346,10 @@ namespace WixToolset.Core.ExtensibilityServices
346
347
public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName)
348
{
349
- var row = this.CreateTuple(section, sourceLineNumbers, TupleDefinitionType.WixEnsureTable);
350
- row.Set(0, tableName);
349
+ section.Tuples.Add(new WixEnsureTableTuple(sourceLineNumbers)
350
+ {
351
+ Table = tableName
352
+ });
353
354
if (this.Creator == null)
355
{
@@ -359,7 +361,7 @@ namespace WixToolset.Core.ExtensibilityServices
361
// instead of a custom table, we get an unresolved reference at link time.
362
if (!this.Creator.TryGetTupleDefinitionByName(tableName, out var ignored))
363
{
362
- this.CreateSimpleReference(section, sourceLineNumbers, "WixCustomTable", tableName);
364
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixCustomTable), tableName);
365
}
366
}
367
@@ -867,11 +869,11 @@ namespace WixToolset.Core.ExtensibilityServices
869
{
870
if (WindowsInstallerStandard.IsStandardAction(beforeAction))
871
{
870
- this.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence.ToString(), beforeAction);
872
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixAction), sequence.ToString(), beforeAction);
873
}
874
else
875
{
874
- this.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", beforeAction);
876
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), beforeAction);
877
}
878
}
879
@@ -879,11 +881,11 @@ namespace WixToolset.Core.ExtensibilityServices
881
{
882
if (WindowsInstallerStandard.IsStandardAction(afterAction))
883
{
882
- this.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence.ToString(), afterAction);
884
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixAction), sequence.ToString(), afterAction);
885
}
886
else
887
{
886
- this.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", afterAction);
888
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), afterAction);
889
}
890
}
891
@@ -907,25 +909,25 @@ namespace WixToolset.Core.ExtensibilityServices
909
this.Creator = (ITupleDefinitionCreator)this.ServiceProvider.GetService(typeof(ITupleDefinitionCreator));
910
}
911
910
- private static IntermediateTuple CreateRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, Identifier identifier)
912
+ private static IntermediateTuple CreateTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, Identifier identifier)
913
{
912
- var row = tupleDefinition.CreateTuple(sourceLineNumbers, identifier);
914
+ var tuple = tupleDefinition.CreateTuple(sourceLineNumbers, identifier);
915
916
if (null != identifier)
917
{
916
- if (row.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number)
918
+ if (tuple.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number)
919
{
918
- row.Set(0, Convert.ToInt32(identifier.Id));
920
+ tuple.Set(0, Convert.ToInt32(identifier.Id));
921
}
922
else
923
{
922
- row.Set(0, identifier.Id);
924
+ tuple.Set(0, identifier.Id);
925
}
926
}
927
926
- section.Tuples.Add(row);
928
+ section.Tuples.Add(tuple);
929
928
- return row;
930
+ return tuple;
931
}
932
933
private static bool TryFindExtension(IEnumerable<ICompilerExtension> extensions, XNamespace ns, out ICompilerExtension extension)