diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-05-23 22:46:40 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-10-07 11:59:14 -0700 |
| commit | 7eb811f1674f210564179254807c7ad9d62b5eab (patch) | |
| tree | f90df3e693f31331d81ae0f579d2a5a79e3cd443 /src | |
| parent | c05d9e61d17746ec6e9e072b32fc821543a7cffb (diff) | |
| download | wix-7eb811f1674f210564179254807c7ad9d62b5eab.tar.gz wix-7eb811f1674f210564179254807c7ad9d62b5eab.tar.bz2 wix-7eb811f1674f210564179254807c7ad9d62b5eab.zip | |
Make uses of EnsureTable more typesafe
And more removal of row for tuple
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index 3318b914..8fbfdd87 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | |||
| @@ -88,7 +88,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | // For anonymous directories, create the identifier. If this identifier already exists in the | 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"). | 92 | // but bloat the intermediate and ultimately make the linker do "busy work"). |
| 93 | if (null == id) | 93 | if (null == id) |
| 94 | { | 94 | { |
| @@ -126,9 +126,9 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 126 | if (1 == inlineSyntax.Length) | 126 | if (1 == inlineSyntax.Length) |
| 127 | { | 127 | { |
| 128 | id = inlineSyntax[0]; | 128 | id = inlineSyntax[0]; |
| 129 | this.CreateSimpleReference(section, sourceLineNumbers, "Directory", id); | 129 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.Directory), id); |
| 130 | } | 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 | { | 132 | { |
| 133 | id = parentId; | 133 | id = parentId; |
| 134 | 134 | ||
| @@ -142,7 +142,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 142 | //} | 142 | //} |
| 143 | 143 | ||
| 144 | id = inlineSyntax[0].TrimEnd(':'); | 144 | id = inlineSyntax[0].TrimEnd(':'); |
| 145 | this.CreateSimpleReference(section, sourceLineNumbers, "Directory", id); | 145 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.Directory), id); |
| 146 | 146 | ||
| 147 | pathStartsAt = 1; | 147 | pathStartsAt = 1; |
| 148 | } | 148 | } |
| @@ -284,14 +284,14 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 284 | throw new ArgumentException(nameof(tableName)); | 284 | throw new ArgumentException(nameof(tableName)); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | return CreateRow(section, sourceLineNumbers, tupleDefinition, identifier); | 287 | return CreateTuple(section, sourceLineNumbers, tupleDefinition, identifier); |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | public IntermediateTuple CreateTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null) | 290 | public IntermediateTuple CreateTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null) |
| 291 | { | 291 | { |
| 292 | var tupleDefinition = TupleDefinitions.ByType(tupleType); | 292 | var tupleDefinition = TupleDefinitions.ByType(tupleType); |
| 293 | 293 | ||
| 294 | return CreateRow(section, sourceLineNumbers, tupleDefinition, identifier); | 294 | return CreateTuple(section, sourceLineNumbers, tupleDefinition, identifier); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | public string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args) | 297 | public string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args) |
| @@ -346,8 +346,10 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 346 | 346 | ||
| 347 | public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName) | 347 | public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName) |
| 348 | { | 348 | { |
| 349 | var row = this.CreateTuple(section, sourceLineNumbers, TupleDefinitionType.WixEnsureTable); | 349 | section.Tuples.Add(new WixEnsureTableTuple(sourceLineNumbers) |
| 350 | row.Set(0, tableName); | 350 | { |
| 351 | Table = tableName | ||
| 352 | }); | ||
| 351 | 353 | ||
| 352 | if (this.Creator == null) | 354 | if (this.Creator == null) |
| 353 | { | 355 | { |
| @@ -359,7 +361,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 359 | // instead of a custom table, we get an unresolved reference at link time. | 361 | // instead of a custom table, we get an unresolved reference at link time. |
| 360 | if (!this.Creator.TryGetTupleDefinitionByName(tableName, out var ignored)) | 362 | if (!this.Creator.TryGetTupleDefinitionByName(tableName, out var ignored)) |
| 361 | { | 363 | { |
| 362 | this.CreateSimpleReference(section, sourceLineNumbers, "WixCustomTable", tableName); | 364 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixCustomTable), tableName); |
| 363 | } | 365 | } |
| 364 | } | 366 | } |
| 365 | 367 | ||
| @@ -867,11 +869,11 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 867 | { | 869 | { |
| 868 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) | 870 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) |
| 869 | { | 871 | { |
| 870 | this.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence.ToString(), beforeAction); | 872 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixAction), sequence.ToString(), beforeAction); |
| 871 | } | 873 | } |
| 872 | else | 874 | else |
| 873 | { | 875 | { |
| 874 | this.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", beforeAction); | 876 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), beforeAction); |
| 875 | } | 877 | } |
| 876 | } | 878 | } |
| 877 | 879 | ||
| @@ -879,11 +881,11 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 879 | { | 881 | { |
| 880 | if (WindowsInstallerStandard.IsStandardAction(afterAction)) | 882 | if (WindowsInstallerStandard.IsStandardAction(afterAction)) |
| 881 | { | 883 | { |
| 882 | this.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence.ToString(), afterAction); | 884 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixAction), sequence.ToString(), afterAction); |
| 883 | } | 885 | } |
| 884 | else | 886 | else |
| 885 | { | 887 | { |
| 886 | this.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", afterAction); | 888 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), afterAction); |
| 887 | } | 889 | } |
| 888 | } | 890 | } |
| 889 | 891 | ||
| @@ -907,25 +909,25 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 907 | this.Creator = (ITupleDefinitionCreator)this.ServiceProvider.GetService(typeof(ITupleDefinitionCreator)); | 909 | this.Creator = (ITupleDefinitionCreator)this.ServiceProvider.GetService(typeof(ITupleDefinitionCreator)); |
| 908 | } | 910 | } |
| 909 | 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) |
| 911 | { | 913 | { |
| 912 | var row = tupleDefinition.CreateTuple(sourceLineNumbers, identifier); | 914 | var tuple = tupleDefinition.CreateTuple(sourceLineNumbers, identifier); |
| 913 | 915 | ||
| 914 | if (null != identifier) | 916 | if (null != identifier) |
| 915 | { | 917 | { |
| 916 | if (row.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number) | 918 | if (tuple.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number) |
| 917 | { | 919 | { |
| 918 | row.Set(0, Convert.ToInt32(identifier.Id)); | 920 | tuple.Set(0, Convert.ToInt32(identifier.Id)); |
| 919 | } | 921 | } |
| 920 | else | 922 | else |
| 921 | { | 923 | { |
| 922 | row.Set(0, identifier.Id); | 924 | tuple.Set(0, identifier.Id); |
| 923 | } | 925 | } |
| 924 | } | 926 | } |
| 925 | 927 | ||
| 926 | section.Tuples.Add(row); | 928 | section.Tuples.Add(tuple); |
| 927 | 929 | ||
| 928 | return row; | 930 | return tuple; |
| 929 | } | 931 | } |
| 930 | 932 | ||
| 931 | private static bool TryFindExtension(IEnumerable<ICompilerExtension> extensions, XNamespace ns, out ICompilerExtension extension) | 933 | private static bool TryFindExtension(IEnumerable<ICompilerExtension> extensions, XNamespace ns, out ICompilerExtension extension) |
