aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Compiler_Bundle.cs
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-04-11 21:49:09 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-04-12 12:46:21 +1000
commit6d8b6f79b44b6a41a630aa3aad5a3c7f16701798 (patch)
treeb82ede9934cb7777a19e74a912c68481e76c21cd /src/WixToolset.Core/Compiler_Bundle.cs
parentdf69d4172d3117d8b66ba51fa5ae7f4be538700d (diff)
downloadwix-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/Compiler_Bundle.cs')
-rw-r--r--src/WixToolset.Core/Compiler_Bundle.cs97
1 files changed, 36 insertions, 61 deletions
diff --git a/src/WixToolset.Core/Compiler_Bundle.cs b/src/WixToolset.Core/Compiler_Bundle.cs
index ff746f8d..a0fe1608 100644
--- a/src/WixToolset.Core/Compiler_Bundle.cs
+++ b/src/WixToolset.Core/Compiler_Bundle.cs
@@ -84,14 +84,12 @@ namespace WixToolset.Core
84 84
85 if (!this.Core.EncounteredError) 85 if (!this.Core.EncounteredError)
86 { 86 {
87 var tuple = new WixApprovedExeForElevationTuple(sourceLineNumbers, id) 87 this.Core.AddTuple(new WixApprovedExeForElevationTuple(sourceLineNumbers, id)
88 { 88 {
89 Key = key, 89 Key = key,
90 ValueName = valueName, 90 ValueName = valueName,
91 Attributes = attributes 91 Attributes = attributes,
92 }; 92 });
93
94 this.Core.AddTuple(tuple);
95 } 93 }
96 } 94 }
97 95
@@ -282,7 +280,7 @@ namespace WixToolset.Core
282 this.ParseBundleExtensionElement(child); 280 this.ParseBundleExtensionElement(child);
283 break; 281 break;
284 case "BundleExtensionRef": 282 case "BundleExtensionRef":
285 this.ParseSimpleRefElement(child, "WixBundleExtension"); 283 this.ParseSimpleRefElement(child, TupleDefinitions.WixBundleExtension);
286 break; 284 break;
287 case "OptionalUpdateRegistration": 285 case "OptionalUpdateRegistration":
288 this.ParseOptionalUpdateRegistrationElement(child, manufacturer, parentName, name); 286 this.ParseOptionalUpdateRegistrationElement(child, manufacturer, parentName, name);
@@ -303,7 +301,7 @@ namespace WixToolset.Core
303 this.ParseContainerElement(child); 301 this.ParseContainerElement(child);
304 break; 302 break;
305 case "ContainerRef": 303 case "ContainerRef":
306 this.ParseSimpleRefElement(child, "WixBundleContainer"); 304 this.ParseSimpleRefElement(child, TupleDefinitions.WixBundleContainer);
307 break; 305 break;
308 case "Log": 306 case "Log":
309 if (logSeen) 307 if (logSeen)
@@ -327,7 +325,7 @@ namespace WixToolset.Core
327 this.ParseSetVariableElement(child); 325 this.ParseSetVariableElement(child);
328 break; 326 break;
329 case "SetVariableRef": 327 case "SetVariableRef":
330 this.ParseSimpleRefElement(child, "WixSetVariable"); 328 this.ParseSimpleRefElement(child, TupleDefinitions.WixSetVariable);
331 break; 329 break;
332 case "Update": 330 case "Update":
333 this.ParseUpdateElement(child); 331 this.ParseUpdateElement(child);
@@ -356,7 +354,7 @@ namespace WixToolset.Core
356 354
357 if (!this.Core.EncounteredError) 355 if (!this.Core.EncounteredError)
358 { 356 {
359 var tuple = new WixBundleTuple(sourceLineNumbers) 357 var tuple = this.Core.AddTuple(new WixBundleTuple(sourceLineNumbers)
360 { 358 {
361 UpgradeCode = upgradeCode, 359 UpgradeCode = upgradeCode,
362 Version = version, 360 Version = version,
@@ -375,7 +373,7 @@ namespace WixToolset.Core
375 Tag = tag, 373 Tag = tag,
376 Platform = this.CurrentPlatform, 374 Platform = this.CurrentPlatform,
377 ParentName = parentName, 375 ParentName = parentName,
378 }; 376 });
379 377
380 if (!String.IsNullOrEmpty(logVariablePrefixAndExtension)) 378 if (!String.IsNullOrEmpty(logVariablePrefixAndExtension))
381 { 379 {
@@ -385,8 +383,6 @@ namespace WixToolset.Core
385 tuple.LogExtension = split[2]; 383 tuple.LogExtension = split[2];
386 } 384 }
387 385
388 this.Core.AddTuple(tuple);;
389
390 if (null != upgradeCode) 386 if (null != upgradeCode)
391 { 387 {
392 this.Core.AddTuple(new WixRelatedBundleTuple(sourceLineNumbers) 388 this.Core.AddTuple(new WixRelatedBundleTuple(sourceLineNumbers)
@@ -399,32 +395,32 @@ namespace WixToolset.Core
399 this.Core.AddTuple(new WixBundleContainerTuple(sourceLineNumbers, Compiler.BurnDefaultAttachedContainerId) 395 this.Core.AddTuple(new WixBundleContainerTuple(sourceLineNumbers, Compiler.BurnDefaultAttachedContainerId)
400 { 396 {
401 Name = "bundle-attached.cab", 397 Name = "bundle-attached.cab",
402 Type = ContainerType.Attached 398 Type = ContainerType.Attached,
403 }); 399 });
404 400
405 // Ensure that the bundle stores the well-known persisted values. 401 // Ensure that the bundle stores the well-known persisted values.
406 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_NAME)) 402 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_NAME))
407 { 403 {
408 Hidden = false, 404 Hidden = false,
409 Persisted = true 405 Persisted = true,
410 }); 406 });
411 407
412 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_ORIGINAL_SOURCE)) 408 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_ORIGINAL_SOURCE))
413 { 409 {
414 Hidden = false, 410 Hidden = false,
415 Persisted = true 411 Persisted = true,
416 }); 412 });
417 413
418 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_ORIGINAL_SOURCE_FOLDER)) 414 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_ORIGINAL_SOURCE_FOLDER))
419 { 415 {
420 Hidden = false, 416 Hidden = false,
421 Persisted = true 417 Persisted = true,
422 }); 418 });
423 419
424 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_LAST_USED_SOURCE)) 420 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, BurnConstants.BURN_BUNDLE_LAST_USED_SOURCE))
425 { 421 {
426 Hidden = false, 422 Hidden = false,
427 Persisted = true 423 Persisted = true,
428 }); 424 });
429 } 425 }
430 } 426 }
@@ -767,7 +763,7 @@ namespace WixToolset.Core
767 } 763 }
768 else 764 else
769 { 765 {
770 this.Core.CreateSimpleReference(sourceLineNumbers, "WixBootstrapperApplication", id); 766 this.Core.CreateSimpleReference(sourceLineNumbers, TupleDefinitions.WixBootstrapperApplication, id);
771 } 767 }
772 } 768 }
773 769
@@ -830,11 +826,10 @@ namespace WixToolset.Core
830 // Add the BundleExtension. 826 // Add the BundleExtension.
831 if (!this.Core.EncounteredError) 827 if (!this.Core.EncounteredError)
832 { 828 {
833 var tuple = new WixBundleExtensionTuple(sourceLineNumbers, id) 829 this.Core.AddTuple(new WixBundleExtensionTuple(sourceLineNumbers, id)
834 { 830 {
835 PayloadRef = id.Id, 831 PayloadRef = id.Id,
836 }; 832 });
837 this.Core.AddTuple(tuple);
838 } 833 }
839 } 834 }
840 835
@@ -1194,7 +1189,7 @@ namespace WixToolset.Core
1194 1189
1195 if (!this.Core.EncounteredError) 1190 if (!this.Core.EncounteredError)
1196 { 1191 {
1197 tuple = new WixBundlePayloadTuple(sourceLineNumbers, id) 1192 tuple = this.Core.AddTuple(new WixBundlePayloadTuple(sourceLineNumbers, id)
1198 { 1193 {
1199 Name = String.IsNullOrEmpty(name) ? Path.GetFileName(sourceFile) : name, 1194 Name = String.IsNullOrEmpty(name) ? Path.GetFileName(sourceFile) : name,
1200 SourceFile = new IntermediateFieldPathValue { Path = sourceFile }, 1195 SourceFile = new IntermediateFieldPathValue { Path = sourceFile },
@@ -1204,7 +1199,7 @@ namespace WixToolset.Core
1204 DisplayName = displayName, 1199 DisplayName = displayName,
1205 Description = description, 1200 Description = description,
1206 EnableSignatureValidation = (YesNoType.Yes == enableSignatureVerification) 1201 EnableSignatureValidation = (YesNoType.Yes == enableSignatureVerification)
1207 }; 1202 });
1208 1203
1209 if (null != remotePayload) 1204 if (null != remotePayload)
1210 { 1205 {
@@ -1217,8 +1212,6 @@ namespace WixToolset.Core
1217 tuple.Version = remotePayload.Version; 1212 tuple.Version = remotePayload.Version;
1218 } 1213 }
1219 1214
1220 this.Core.AddTuple(tuple);
1221
1222 this.CreateGroupAndOrderingRows(sourceLineNumbers, parentType, parentId.Id, ComplexReferenceChildType.Payload, id.Id, previousType, previousId?.Id); 1215 this.CreateGroupAndOrderingRows(sourceLineNumbers, parentType, parentId.Id, ComplexReferenceChildType.Payload, id.Id, previousType, previousId?.Id);
1223 } 1216 }
1224 1217
@@ -1322,7 +1315,7 @@ namespace WixToolset.Core
1322 { 1315 {
1323 case "Id": 1316 case "Id":
1324 id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); 1317 id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
1325 this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePayloadGroup", id.Id); 1318 this.Core.CreateSimpleReference(sourceLineNumbers, TupleDefinitions.WixBundlePayloadGroup, id.Id);
1326 break; 1319 break;
1327 default: 1320 default:
1328 this.Core.UnexpectedAttribute(node, attrib); 1321 this.Core.UnexpectedAttribute(node, attrib);
@@ -1377,15 +1370,13 @@ namespace WixToolset.Core
1377 // TODO: Should we define our own enum for this, just to ensure there's no "cross-contamination"? 1370 // TODO: Should we define our own enum for this, just to ensure there's no "cross-contamination"?
1378 // TODO: Also, we could potentially include an 'Attributes' field to track things like 1371 // TODO: Also, we could potentially include an 'Attributes' field to track things like
1379 // 'before' vs. 'after', and explicit vs. inferred dependencies. 1372 // 'before' vs. 'after', and explicit vs. inferred dependencies.
1380 var tuple = new WixOrderingTuple(sourceLineNumbers) 1373 this.Core.AddTuple(new WixOrderingTuple(sourceLineNumbers)
1381 { 1374 {
1382 ItemType = type, 1375 ItemType = type,
1383 ItemIdRef = id, 1376 ItemIdRef = id,
1384 DependsOnType = previousType, 1377 DependsOnType = previousType,
1385 DependsOnIdRef = previousId 1378 DependsOnIdRef = previousId
1386 }; 1379 });
1387
1388 this.Core.AddTuple(tuple);
1389 } 1380 }
1390 } 1381 }
1391 1382
@@ -2101,7 +2092,7 @@ namespace WixToolset.Core
2101 attributes |= (YesNoType.Yes == permanent) ? WixBundlePackageAttributes.Permanent : 0; 2092 attributes |= (YesNoType.Yes == permanent) ? WixBundlePackageAttributes.Permanent : 0;
2102 attributes |= (YesNoType.Yes == visible) ? WixBundlePackageAttributes.Visible : 0; 2093 attributes |= (YesNoType.Yes == visible) ? WixBundlePackageAttributes.Visible : 0;
2103 2094
2104 var chainPackageTuple = new WixBundlePackageTuple(sourceLineNumbers, id) 2095 var chainPackageTuple = this.Core.AddTuple(new WixBundlePackageTuple(sourceLineNumbers, id)
2105 { 2096 {
2106 Type = packageType, 2097 Type = packageType,
2107 PayloadRef = id.Id, 2098 PayloadRef = id.Id,
@@ -2110,7 +2101,7 @@ namespace WixToolset.Core
2110 CacheId = cacheId, 2101 CacheId = cacheId,
2111 LogPathVariable = logPathVariable, 2102 LogPathVariable = logPathVariable,
2112 RollbackLogPathVariable = rollbackPathVariable, 2103 RollbackLogPathVariable = rollbackPathVariable,
2113 }; 2104 });
2114 2105
2115 if (YesNoAlwaysType.NotSet != cache) 2106 if (YesNoAlwaysType.NotSet != cache)
2116 { 2107 {
@@ -2132,8 +2123,6 @@ namespace WixToolset.Core
2132 chainPackageTuple.InstallSize = installSize; 2123 chainPackageTuple.InstallSize = installSize;
2133 } 2124 }
2134 2125
2135 this.Core.AddTuple(chainPackageTuple);
2136
2137 switch (packageType) 2126 switch (packageType)
2138 { 2127 {
2139 case WixBundlePackageType.Exe: 2128 case WixBundlePackageType.Exe:
@@ -2370,7 +2359,7 @@ namespace WixToolset.Core
2370 { 2359 {
2371 case "Id": 2360 case "Id":
2372 id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); 2361 id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2373 this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePackageGroup", id); 2362 this.Core.CreateSimpleReference(sourceLineNumbers, TupleDefinitions.WixBundlePackageGroup, id);
2374 break; 2363 break;
2375 case "After": 2364 case "After":
2376 after = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); 2365 after = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
@@ -2425,7 +2414,7 @@ namespace WixToolset.Core
2425 { 2414 {
2426 this.Core.AddTuple(new WixChainItemTuple(sourceLineNumbers, id)); 2415 this.Core.AddTuple(new WixChainItemTuple(sourceLineNumbers, id));
2427 2416
2428 var rollbackBoundary = new WixBundleRollbackBoundaryTuple(sourceLineNumbers, id); 2417 var rollbackBoundary = this.Core.AddTuple(new WixBundleRollbackBoundaryTuple(sourceLineNumbers, id));
2429 2418
2430 if (YesNoType.NotSet != vital) 2419 if (YesNoType.NotSet != vital)
2431 { 2420 {
@@ -2437,8 +2426,6 @@ namespace WixToolset.Core
2437 rollbackBoundary.Transaction = (transaction == YesNoType.Yes); 2426 rollbackBoundary.Transaction = (transaction == YesNoType.Yes);
2438 } 2427 }
2439 2428
2440 this.Core.AddTuple(rollbackBoundary);
2441
2442 this.CreateChainPackageMetaRows(sourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Package, id.Id, previousType, previousId, null); 2429 this.CreateChainPackageMetaRows(sourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Package, id.Id, previousType, previousId, null);
2443 } 2430 }
2444 2431
@@ -2520,19 +2507,17 @@ namespace WixToolset.Core
2520 2507
2521 if (!this.Core.EncounteredError) 2508 if (!this.Core.EncounteredError)
2522 { 2509 {
2523 var tuple = new WixBundleMsiPropertyTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, packageId, name)) 2510 var tuple = this.Core.AddTuple(new WixBundleMsiPropertyTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, packageId, name))
2524 { 2511 {
2525 PackageRef = packageId, 2512 PackageRef = packageId,
2526 Name = name, 2513 Name = name,
2527 Value = value 2514 Value = value
2528 }; 2515 });
2529 2516
2530 if (!String.IsNullOrEmpty(condition)) 2517 if (!String.IsNullOrEmpty(condition))
2531 { 2518 {
2532 tuple.Condition = condition; 2519 tuple.Condition = condition;
2533 } 2520 }
2534
2535 this.Core.AddTuple(tuple);
2536 } 2521 }
2537 } 2522 }
2538 2523
@@ -2554,7 +2539,7 @@ namespace WixToolset.Core
2554 { 2539 {
2555 case "Id": 2540 case "Id":
2556 id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); 2541 id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2557 this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePackage", id); 2542 this.Core.CreateSimpleReference(sourceLineNumbers, TupleDefinitions.WixBundlePackage, id);
2558 break; 2543 break;
2559 default: 2544 default:
2560 this.Core.UnexpectedAttribute(node, attrib); 2545 this.Core.UnexpectedAttribute(node, attrib);
@@ -2650,16 +2635,11 @@ namespace WixToolset.Core
2650 2635
2651 if (!this.Core.EncounteredError) 2636 if (!this.Core.EncounteredError)
2652 { 2637 {
2653 var tuple = new WixRelatedBundleTuple(sourceLineNumbers) 2638 this.Core.AddTuple(new WixRelatedBundleTuple(sourceLineNumbers)
2654 { 2639 {
2655 BundleId = id, 2640 BundleId = id,
2656 Action = actionType, 2641 Action = actionType,
2657 }; 2642 });
2658
2659 this.Core.AddTuple(tuple);
2660 //var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixRelatedBundle);
2661 //row.Set(0, id);
2662 //row.Set(1, (int)actionType);
2663 } 2643 }
2664 } 2644 }
2665 2645
@@ -2701,12 +2681,10 @@ namespace WixToolset.Core
2701 2681
2702 if (!this.Core.EncounteredError) 2682 if (!this.Core.EncounteredError)
2703 { 2683 {
2704 var tuple = new WixBundleUpdateTuple(sourceLineNumbers) 2684 this.Core.AddTuple(new WixBundleUpdateTuple(sourceLineNumbers)
2705 { 2685 {
2706 Location = location 2686 Location = location
2707 }; 2687 });
2708
2709 this.Core.AddTuple(tuple);
2710 } 2688 }
2711 } 2689 }
2712 2690
@@ -2773,12 +2751,11 @@ namespace WixToolset.Core
2773 2751
2774 if (!this.Messaging.EncounteredError) 2752 if (!this.Messaging.EncounteredError)
2775 { 2753 {
2776 var tuple = new WixSetVariableTuple(sourceLineNumbers, id) 2754 this.Core.AddTuple(new WixSetVariableTuple(sourceLineNumbers, id)
2777 { 2755 {
2778 Value = value, 2756 Value = value,
2779 Type = type, 2757 Type = type,
2780 }; 2758 });
2781 this.Core.AddTuple(tuple);
2782 } 2759 }
2783 } 2760 }
2784 2761
@@ -2848,15 +2825,13 @@ namespace WixToolset.Core
2848 2825
2849 if (!this.Core.EncounteredError) 2826 if (!this.Core.EncounteredError)
2850 { 2827 {
2851 var tuple = new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, name)) 2828 this.Core.AddTuple(new WixBundleVariableTuple(sourceLineNumbers, new Identifier(AccessModifier.Private, name))
2852 { 2829 {
2853 Value = value, 2830 Value = value,
2854 Type = type, 2831 Type = type,
2855 Hidden = hidden, 2832 Hidden = hidden,
2856 Persisted = persisted 2833 Persisted = persisted
2857 }; 2834 });
2858
2859 this.Core.AddTuple(tuple);
2860 } 2835 }
2861 } 2836 }
2862 2837