diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-04-11 21:49:09 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-04-12 12:46:21 +1000 |
| commit | 6d8b6f79b44b6a41a630aa3aad5a3c7f16701798 (patch) | |
| tree | b82ede9934cb7777a19e74a912c68481e76c21cd /src/WixToolset.Core/ExtensibilityServices | |
| parent | df69d4172d3117d8b66ba51fa5ae7f4be538700d (diff) | |
| download | wix-6d8b6f79b44b6a41a630aa3aad5a3c7f16701798.tar.gz wix-6d8b6f79b44b6a41a630aa3aad5a3c7f16701798.tar.bz2 wix-6d8b6f79b44b6a41a630aa3aad5a3c7f16701798.zip | |
General cleanup.
Try not to send strings to specify the tuple or table.
Try to avoid using the Set method on tuples.
Always create new tuples and add them to the section in the same line.
Diffstat (limited to 'src/WixToolset.Core/ExtensibilityServices')
| -rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | 115 |
1 files changed, 51 insertions, 64 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index f07e4638..3c092bd4 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | |||
| @@ -54,7 +54,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 54 | public void CreateComplexReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary) | 54 | public void CreateComplexReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary) |
| 55 | { | 55 | { |
| 56 | 56 | ||
| 57 | var tuple = new WixComplexReferenceTuple(sourceLineNumbers) | 57 | section.AddTuple(new WixComplexReferenceTuple(sourceLineNumbers) |
| 58 | { | 58 | { |
| 59 | Parent = parentId, | 59 | Parent = parentId, |
| 60 | ParentType = parentType, | 60 | ParentType = parentType, |
| @@ -62,9 +62,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 62 | Child = childId, | 62 | Child = childId, |
| 63 | ChildType = childType, | 63 | ChildType = childType, |
| 64 | IsPrimary = isPrimary | 64 | IsPrimary = isPrimary |
| 65 | }; | 65 | }); |
| 66 | |||
| 67 | section.Tuples.Add(tuple); | ||
| 68 | 66 | ||
| 69 | this.CreateWixGroupTuple(section, sourceLineNumbers, parentType, parentId, childType, childId); | 67 | this.CreateWixGroupTuple(section, sourceLineNumbers, parentType, parentId, childType, childId); |
| 70 | } | 68 | } |
| @@ -100,24 +98,22 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 100 | } | 98 | } |
| 101 | } | 99 | } |
| 102 | 100 | ||
| 103 | var tuple = new DirectoryTuple(sourceLineNumbers, id) | 101 | var tuple = section.AddTuple(new DirectoryTuple(sourceLineNumbers, id) |
| 104 | { | 102 | { |
| 105 | ParentDirectoryRef = parentId, | 103 | ParentDirectoryRef = parentId, |
| 106 | Name = name, | 104 | Name = name, |
| 107 | ShortName = shortName, | 105 | ShortName = shortName, |
| 108 | SourceName = sourceName, | 106 | SourceName = sourceName, |
| 109 | SourceShortName = shortSourceName | 107 | SourceShortName = shortSourceName |
| 110 | }; | 108 | }); |
| 111 | |||
| 112 | section.Tuples.Add(tuple); | ||
| 113 | 109 | ||
| 114 | return id; | 110 | return tuple.Id; |
| 115 | } | 111 | } |
| 116 | 112 | ||
| 117 | public string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, string parentId, XAttribute attribute, ISet<string> sectionInlinedDirectoryIds) | 113 | public string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, string parentId, XAttribute attribute, ISet<string> sectionInlinedDirectoryIds) |
| 118 | { | 114 | { |
| 119 | string id = null; | 115 | string id = null; |
| 120 | string[] inlineSyntax = this.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, true); | 116 | var inlineSyntax = this.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, true); |
| 121 | 117 | ||
| 122 | if (null != inlineSyntax) | 118 | if (null != inlineSyntax) |
| 123 | { | 119 | { |
| @@ -126,13 +122,13 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 126 | if (1 == inlineSyntax.Length) | 122 | if (1 == inlineSyntax.Length) |
| 127 | { | 123 | { |
| 128 | id = inlineSyntax[0]; | 124 | id = inlineSyntax[0]; |
| 129 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.Directory), id); | 125 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Directory, id); |
| 130 | } | 126 | } |
| 131 | else // start creating tuples for the entries in the inline syntax | 127 | else // start creating tuples for the entries in the inline syntax |
| 132 | { | 128 | { |
| 133 | id = parentId; | 129 | id = parentId; |
| 134 | 130 | ||
| 135 | int pathStartsAt = 0; | 131 | var pathStartsAt = 0; |
| 136 | if (inlineSyntax[0].EndsWith(":")) | 132 | if (inlineSyntax[0].EndsWith(":")) |
| 137 | { | 133 | { |
| 138 | // TODO: should overriding the parent identifier with a specific id be an error or a warning or just let it slide? | 134 | // TODO: should overriding the parent identifier with a specific id be an error or a warning or just let it slide? |
| @@ -142,14 +138,14 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 142 | //} | 138 | //} |
| 143 | 139 | ||
| 144 | id = inlineSyntax[0].TrimEnd(':'); | 140 | id = inlineSyntax[0].TrimEnd(':'); |
| 145 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.Directory), id); | 141 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Directory, id); |
| 146 | 142 | ||
| 147 | pathStartsAt = 1; | 143 | pathStartsAt = 1; |
| 148 | } | 144 | } |
| 149 | 145 | ||
| 150 | for (int i = pathStartsAt; i < inlineSyntax.Length; ++i) | 146 | for (var i = pathStartsAt; i < inlineSyntax.Length; ++i) |
| 151 | { | 147 | { |
| 152 | Identifier inlineId = this.CreateDirectoryTuple(section, sourceLineNumbers, null, id, inlineSyntax[i], sectionInlinedDirectoryIds); | 148 | var inlineId = this.CreateDirectoryTuple(section, sourceLineNumbers, null, id, inlineSyntax[i], sectionInlinedDirectoryIds); |
| 153 | id = inlineId.Id; | 149 | id = inlineId.Id; |
| 154 | } | 150 | } |
| 155 | } | 151 | } |
| @@ -206,29 +202,25 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 206 | 202 | ||
| 207 | var id = this.CreateIdentifier("reg", componentId, ((int)root).ToString(CultureInfo.InvariantCulture.NumberFormat), key.ToLowerInvariant(), (null != name ? name.ToLowerInvariant() : name)); | 203 | var id = this.CreateIdentifier("reg", componentId, ((int)root).ToString(CultureInfo.InvariantCulture.NumberFormat), key.ToLowerInvariant(), (null != name ? name.ToLowerInvariant() : name)); |
| 208 | 204 | ||
| 209 | var tuple = new RegistryTuple(sourceLineNumbers, id) | 205 | var tuple = section.AddTuple(new RegistryTuple(sourceLineNumbers, id) |
| 210 | { | 206 | { |
| 211 | Root = root, | 207 | Root = root, |
| 212 | Key = key, | 208 | Key = key, |
| 213 | Name = name, | 209 | Name = name, |
| 214 | Value = value, | 210 | Value = value, |
| 215 | ComponentRef = componentId, | 211 | ComponentRef = componentId, |
| 216 | }; | 212 | }); |
| 217 | |||
| 218 | section.Tuples.Add(tuple); | ||
| 219 | 213 | ||
| 220 | return id; | 214 | return tuple.Id; |
| 221 | } | 215 | } |
| 222 | 216 | ||
| 223 | public void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tupleName, params string[] primaryKeys) | 217 | public void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tupleName, params string[] primaryKeys) |
| 224 | { | 218 | { |
| 225 | var tuple = new WixSimpleReferenceTuple(sourceLineNumbers) | 219 | section.AddTuple(new WixSimpleReferenceTuple(sourceLineNumbers) |
| 226 | { | 220 | { |
| 227 | Table = tupleName, | 221 | Table = tupleName, |
| 228 | PrimaryKeys = String.Join("/", primaryKeys) | 222 | PrimaryKeys = String.Join("/", primaryKeys) |
| 229 | }; | 223 | }); |
| 230 | |||
| 231 | section.Tuples.Add(tuple); | ||
| 232 | } | 224 | } |
| 233 | 225 | ||
| 234 | public void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, params string[] primaryKeys) | 226 | public void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, params string[] primaryKeys) |
| @@ -254,15 +246,13 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 254 | throw new ArgumentNullException("childId"); | 246 | throw new ArgumentNullException("childId"); |
| 255 | } | 247 | } |
| 256 | 248 | ||
| 257 | var tuple = new WixGroupTuple(sourceLineNumbers) | 249 | section.AddTuple(new WixGroupTuple(sourceLineNumbers) |
| 258 | { | 250 | { |
| 259 | ParentId = parentId, | 251 | ParentId = parentId, |
| 260 | ParentType = parentType, | 252 | ParentType = parentType, |
| 261 | ChildId = childId, | 253 | ChildId = childId, |
| 262 | ChildType = childType, | 254 | ChildType = childType, |
| 263 | }; | 255 | }); |
| 264 | |||
| 265 | section.Tuples.Add(tuple); | ||
| 266 | } | 256 | } |
| 267 | 257 | ||
| 268 | public void CreateWixSearchTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, string elementName, Identifier id, string variable, string condition, string after, string bundleExtensionId) | 258 | public void CreateWixSearchTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, string elementName, Identifier id, string variable, string condition, string after, string bundleExtensionId) |
| @@ -273,7 +263,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 273 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, elementName, "Variable")); | 263 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, elementName, "Variable")); |
| 274 | } | 264 | } |
| 275 | 265 | ||
| 276 | section.Tuples.Add(new WixSearchTuple(sourceLineNumbers, id) | 266 | section.AddTuple(new WixSearchTuple(sourceLineNumbers, id) |
| 277 | { | 267 | { |
| 278 | Variable = variable, | 268 | Variable = variable, |
| 279 | Condition = condition, | 269 | Condition = condition, |
| @@ -282,20 +272,20 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 282 | 272 | ||
| 283 | if (after != null) | 273 | if (after != null) |
| 284 | { | 274 | { |
| 285 | this.CreateSimpleReference(section, sourceLineNumbers, "WixSearch", after); | 275 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixSearch, after); |
| 286 | // TODO: We're currently defaulting to "always run after", which we will need to change... | 276 | // TODO: We're currently defaulting to "always run after", which we will need to change... |
| 287 | this.CreateWixSearchRelationTuple(section, sourceLineNumbers, id, after, 2); | 277 | this.CreateWixSearchRelationTuple(section, sourceLineNumbers, id, after, 2); |
| 288 | } | 278 | } |
| 289 | 279 | ||
| 290 | if (!String.IsNullOrEmpty(bundleExtensionId)) | 280 | if (!String.IsNullOrEmpty(bundleExtensionId)) |
| 291 | { | 281 | { |
| 292 | this.CreateSimpleReference(section, sourceLineNumbers, "WixBundleExtension", bundleExtensionId); | 282 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixBundleExtension, bundleExtensionId); |
| 293 | } | 283 | } |
| 294 | } | 284 | } |
| 295 | 285 | ||
| 296 | public void CreateWixSearchRelationTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, int attributes) | 286 | public void CreateWixSearchRelationTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, int attributes) |
| 297 | { | 287 | { |
| 298 | section.Tuples.Add(new WixSearchRelationTuple(sourceLineNumbers, id) | 288 | section.AddTuple(new WixSearchRelationTuple(sourceLineNumbers, id) |
| 299 | { | 289 | { |
| 300 | ParentSearchRef = parentId, | 290 | ParentSearchRef = parentId, |
| 301 | Attributes = attributes, | 291 | Attributes = attributes, |
| @@ -351,13 +341,13 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 351 | } | 341 | } |
| 352 | 342 | ||
| 353 | // collect all the data | 343 | // collect all the data |
| 354 | List<string> strings = new List<string>(1 + args.Length); | 344 | var strings = new List<string>(1 + args.Length); |
| 355 | strings.Add(longName); | 345 | strings.Add(longName); |
| 356 | strings.AddRange(args); | 346 | strings.AddRange(args); |
| 357 | 347 | ||
| 358 | // prepare for hashing | 348 | // prepare for hashing |
| 359 | string stringData = String.Join("|", strings); | 349 | var stringData = String.Join("|", strings); |
| 360 | byte[] data = Encoding.UTF8.GetBytes(stringData); | 350 | var data = Encoding.UTF8.GetBytes(stringData); |
| 361 | 351 | ||
| 362 | // hash the data | 352 | // hash the data |
| 363 | byte[] hash; | 353 | byte[] hash; |
| @@ -367,12 +357,12 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 367 | } | 357 | } |
| 368 | 358 | ||
| 369 | // generate the short file/directory name without an extension | 359 | // generate the short file/directory name without an extension |
| 370 | StringBuilder shortName = new StringBuilder(Convert.ToBase64String(hash)); | 360 | var shortName = new StringBuilder(Convert.ToBase64String(hash)); |
| 371 | shortName.Remove(8, shortName.Length - 8).Replace('+', '-').Replace('/', '_'); | 361 | shortName.Remove(8, shortName.Length - 8).Replace('+', '-').Replace('/', '_'); |
| 372 | 362 | ||
| 373 | if (keepExtension) | 363 | if (keepExtension) |
| 374 | { | 364 | { |
| 375 | string extension = Path.GetExtension(longName); | 365 | var extension = Path.GetExtension(longName); |
| 376 | 366 | ||
| 377 | if (4 < extension.Length) | 367 | if (4 < extension.Length) |
| 378 | { | 368 | { |
| @@ -405,9 +395,9 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 405 | 395 | ||
| 406 | public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName) | 396 | public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName) |
| 407 | { | 397 | { |
| 408 | section.Tuples.Add(new WixEnsureTableTuple(sourceLineNumbers) | 398 | section.AddTuple(new WixEnsureTableTuple(sourceLineNumbers) |
| 409 | { | 399 | { |
| 410 | Table = tableName | 400 | Table = tableName, |
| 411 | }); | 401 | }); |
| 412 | 402 | ||
| 413 | if (this.Creator == null) | 403 | if (this.Creator == null) |
| @@ -419,7 +409,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 419 | // We don't add custom table definitions to the tableDefinitions collection, | 409 | // We don't add custom table definitions to the tableDefinitions collection, |
| 420 | // so if it's not in there, it better be a custom table. If the Id is just wrong, | 410 | // so if it's not in there, it better be a custom table. If the Id is just wrong, |
| 421 | // instead of a custom table, we get an unresolved reference at link time. | 411 | // instead of a custom table, we get an unresolved reference at link time. |
| 422 | if (!this.Creator.TryGetTupleDefinitionByName(tableName, out var ignored)) | 412 | if (!this.Creator.TryGetTupleDefinitionByName(tableName, out var _)) |
| 423 | { | 413 | { |
| 424 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixCustomTable, tableName); | 414 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixCustomTable, tableName); |
| 425 | } | 415 | } |
| @@ -432,8 +422,8 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 432 | throw new ArgumentNullException("attribute"); | 422 | throw new ArgumentNullException("attribute"); |
| 433 | } | 423 | } |
| 434 | 424 | ||
| 435 | EmptyRule emptyRule = canBeEmpty ? EmptyRule.CanBeEmpty : EmptyRule.CanBeWhitespaceOnly; | 425 | var emptyRule = canBeEmpty ? EmptyRule.CanBeEmpty : EmptyRule.CanBeWhitespaceOnly; |
| 436 | string value = this.GetAttributeValue(sourceLineNumbers, attribute, emptyRule); | 426 | var value = this.GetAttributeValue(sourceLineNumbers, attribute, emptyRule); |
| 437 | 427 | ||
| 438 | if (String.IsNullOrEmpty(value) && canBeEmpty) | 428 | if (String.IsNullOrEmpty(value) && canBeEmpty) |
| 439 | { | 429 | { |
| @@ -516,15 +506,15 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 516 | public string[] GetAttributeInlineDirectorySyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool resultUsedToCreateReference = false) | 506 | public string[] GetAttributeInlineDirectorySyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool resultUsedToCreateReference = false) |
| 517 | { | 507 | { |
| 518 | string[] result = null; | 508 | string[] result = null; |
| 519 | string value = this.GetAttributeValue(sourceLineNumbers, attribute); | 509 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); |
| 520 | 510 | ||
| 521 | if (!String.IsNullOrEmpty(value)) | 511 | if (!String.IsNullOrEmpty(value)) |
| 522 | { | 512 | { |
| 523 | int pathStartsAt = 0; | 513 | var pathStartsAt = 0; |
| 524 | result = value.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); | 514 | result = value.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); |
| 525 | if (result[0].EndsWith(":", StringComparison.Ordinal)) | 515 | if (result[0].EndsWith(":", StringComparison.Ordinal)) |
| 526 | { | 516 | { |
| 527 | string id = result[0].TrimEnd(':'); | 517 | var id = result[0].TrimEnd(':'); |
| 528 | if (1 == result.Length) | 518 | if (1 == result.Length) |
| 529 | { | 519 | { |
| 530 | this.Messaging.Write(ErrorMessages.InlineDirectorySyntaxRequiresPath(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, id)); | 520 | this.Messaging.Write(ErrorMessages.InlineDirectorySyntaxRequiresPath(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, id)); |
| @@ -558,7 +548,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 558 | } | 548 | } |
| 559 | 549 | ||
| 560 | // Check each part of the relative path to ensure that it is a valid directory name. | 550 | // Check each part of the relative path to ensure that it is a valid directory name. |
| 561 | for (int i = pathStartsAt; i < result.Length; ++i) | 551 | for (var i = pathStartsAt; i < result.Length; ++i) |
| 562 | { | 552 | { |
| 563 | if (!this.IsValidLongFilename(result[i], false, false)) | 553 | if (!this.IsValidLongFilename(result[i], false, false)) |
| 564 | { | 554 | { |
| @@ -588,7 +578,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 588 | throw new ArgumentNullException("attribute"); | 578 | throw new ArgumentNullException("attribute"); |
| 589 | } | 579 | } |
| 590 | 580 | ||
| 591 | string value = this.GetAttributeValue(sourceLineNumbers, attribute); | 581 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); |
| 592 | 582 | ||
| 593 | if (0 < value.Length) | 583 | if (0 < value.Length) |
| 594 | { | 584 | { |
| @@ -605,7 +595,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 605 | } | 595 | } |
| 606 | else if (allowRelative) | 596 | else if (allowRelative) |
| 607 | { | 597 | { |
| 608 | string normalizedPath = value.Replace('\\', '/'); | 598 | var normalizedPath = value.Replace('\\', '/'); |
| 609 | if (normalizedPath.StartsWith("../", StringComparison.Ordinal) || normalizedPath.Contains("/../")) | 599 | if (normalizedPath.StartsWith("../", StringComparison.Ordinal) || normalizedPath.Contains("/../")) |
| 610 | { | 600 | { |
| 611 | this.Messaging.Write(ErrorMessages.PayloadMustBeRelativeToCache(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); | 601 | this.Messaging.Write(ErrorMessages.PayloadMustBeRelativeToCache(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value)); |
| @@ -624,13 +614,13 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 624 | { | 614 | { |
| 625 | Debug.Assert(minimum > CompilerConstants.LongNotSet && minimum > CompilerConstants.IllegalLong, "The legal values for this attribute collide with at least one sentinel used during parsing."); | 615 | Debug.Assert(minimum > CompilerConstants.LongNotSet && minimum > CompilerConstants.IllegalLong, "The legal values for this attribute collide with at least one sentinel used during parsing."); |
| 626 | 616 | ||
| 627 | string value = this.GetAttributeValue(sourceLineNumbers, attribute); | 617 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); |
| 628 | 618 | ||
| 629 | if (0 < value.Length) | 619 | if (0 < value.Length) |
| 630 | { | 620 | { |
| 631 | try | 621 | try |
| 632 | { | 622 | { |
| 633 | long longValue = Convert.ToInt64(value, CultureInfo.InvariantCulture.NumberFormat); | 623 | var longValue = Convert.ToInt64(value, CultureInfo.InvariantCulture.NumberFormat); |
| 634 | 624 | ||
| 635 | if (CompilerConstants.LongNotSet == longValue || CompilerConstants.IllegalLong == longValue) | 625 | if (CompilerConstants.LongNotSet == longValue || CompilerConstants.IllegalLong == longValue) |
| 636 | { | 626 | { |
| @@ -664,7 +654,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 664 | 654 | ||
| 665 | public RegistryRootType? GetAttributeRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu) | 655 | public RegistryRootType? GetAttributeRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu) |
| 666 | { | 656 | { |
| 667 | string value = this.GetAttributeValue(sourceLineNumbers, attribute); | 657 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); |
| 668 | if (String.IsNullOrEmpty(value)) | 658 | if (String.IsNullOrEmpty(value)) |
| 669 | { | 659 | { |
| 670 | return null; | 660 | return null; |
| @@ -814,8 +804,8 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 814 | } | 804 | } |
| 815 | 805 | ||
| 816 | // Check for a non-period character (all periods is not legal) | 806 | // Check for a non-period character (all periods is not legal) |
| 817 | bool nonPeriodFound = false; | 807 | var nonPeriodFound = false; |
| 818 | foreach (char character in filename) | 808 | foreach (var character in filename) |
| 819 | { | 809 | { |
| 820 | if ('.' != character) | 810 | if ('.' != character) |
| 821 | { | 811 | { |
| @@ -867,7 +857,6 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 867 | { | 857 | { |
| 868 | if (ParseHelper.TryFindExtension(extensions, element.Name.Namespace, out var extension)) | 858 | if (ParseHelper.TryFindExtension(extensions, element.Name.Namespace, out var extension)) |
| 869 | { | 859 | { |
| 870 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); | ||
| 871 | extension.ParseElement(intermediate, section, parentElement, element, context); | 860 | extension.ParseElement(intermediate, section, parentElement, element, context); |
| 872 | } | 861 | } |
| 873 | else | 862 | else |
| @@ -896,7 +885,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 896 | 885 | ||
| 897 | public void ParseForExtensionElements(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement element) | 886 | public void ParseForExtensionElements(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement element) |
| 898 | { | 887 | { |
| 899 | foreach (XElement child in element.Elements()) | 888 | foreach (var child in element.Elements()) |
| 900 | { | 889 | { |
| 901 | if (element.Name.Namespace == child.Name.Namespace) | 890 | if (element.Name.Namespace == child.Name.Namespace) |
| 902 | { | 891 | { |
| @@ -913,7 +902,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 913 | { | 902 | { |
| 914 | var actionId = new Identifier(access, sequence, actionName); | 903 | var actionId = new Identifier(access, sequence, actionName); |
| 915 | 904 | ||
| 916 | var actionTuple = new WixActionTuple(sourceLineNumbers, actionId) | 905 | var actionTuple = section.AddTuple(new WixActionTuple(sourceLineNumbers, actionId) |
| 917 | { | 906 | { |
| 918 | SequenceTable = sequence, | 907 | SequenceTable = sequence, |
| 919 | Action = actionName, | 908 | Action = actionName, |
| @@ -921,19 +910,17 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 921 | Before = beforeAction, | 910 | Before = beforeAction, |
| 922 | After = afterAction, | 911 | After = afterAction, |
| 923 | Overridable = overridable, | 912 | Overridable = overridable, |
| 924 | }; | 913 | }); |
| 925 | |||
| 926 | section.Tuples.Add(actionTuple); | ||
| 927 | 914 | ||
| 928 | if (null != beforeAction) | 915 | if (null != beforeAction) |
| 929 | { | 916 | { |
| 930 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) | 917 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) |
| 931 | { | 918 | { |
| 932 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixAction), sequence.ToString(), beforeAction); | 919 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixAction, sequence.ToString(), beforeAction); |
| 933 | } | 920 | } |
| 934 | else | 921 | else |
| 935 | { | 922 | { |
| 936 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), beforeAction); | 923 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, beforeAction); |
| 937 | } | 924 | } |
| 938 | } | 925 | } |
| 939 | 926 | ||
| @@ -941,11 +928,11 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 941 | { | 928 | { |
| 942 | if (WindowsInstallerStandard.IsStandardAction(afterAction)) | 929 | if (WindowsInstallerStandard.IsStandardAction(afterAction)) |
| 943 | { | 930 | { |
| 944 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.WixAction), sequence.ToString(), afterAction); | 931 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixAction, sequence.ToString(), afterAction); |
| 945 | } | 932 | } |
| 946 | else | 933 | else |
| 947 | { | 934 | { |
| 948 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), afterAction); | 935 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, afterAction); |
| 949 | } | 936 | } |
| 950 | } | 937 | } |
| 951 | 938 | ||
| @@ -981,7 +968,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 981 | break; | 968 | break; |
| 982 | } | 969 | } |
| 983 | 970 | ||
| 984 | this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), name + suffix); | 971 | this.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, name + suffix); |
| 985 | } | 972 | } |
| 986 | } | 973 | } |
| 987 | 974 | ||
