aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Link/WixGroupingOrdering.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Link/WixGroupingOrdering.cs')
-rw-r--r--src/WixToolset.Core/Link/WixGroupingOrdering.cs57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/WixToolset.Core/Link/WixGroupingOrdering.cs b/src/WixToolset.Core/Link/WixGroupingOrdering.cs
index 4e89e607..c40af502 100644
--- a/src/WixToolset.Core/Link/WixGroupingOrdering.cs
+++ b/src/WixToolset.Core/Link/WixGroupingOrdering.cs
@@ -18,11 +18,11 @@ namespace WixToolset.Core.Link
18 /// </summary> 18 /// </summary>
19 internal class WixGroupingOrdering 19 internal class WixGroupingOrdering
20 { 20 {
21 private IMessaging messageHandler; 21 private readonly IMessaging messageHandler;
22 private List<string> groupTypes; 22 private List<string> groupTypes;
23 private List<string> itemTypes; 23 private List<string> itemTypes;
24 private ItemCollection items; 24 private ItemCollection items;
25 private List<int> rowsUsed; 25 private readonly List<int> rowsUsed;
26 private bool loaded; 26 private bool loaded;
27 private bool encounteredError; 27 private bool encounteredError;
28 28
@@ -50,10 +50,10 @@ namespace WixToolset.Core.Link
50 /// </summary> 50 /// </summary>
51 /// <param name="groupTypes">Group types to include.</param> 51 /// <param name="groupTypes">Group types to include.</param>
52 /// <param name="itemTypes">Item types to include.</param> 52 /// <param name="itemTypes">Item types to include.</param>
53 public void UseTypes(IEnumerable<string> groupTypes, IEnumerable<string> itemTypes) 53 public void UseTypes(IEnumerable<ComplexReferenceParentType> groupTypes, IEnumerable<ComplexReferenceChildType> itemTypes)
54 { 54 {
55 this.groupTypes = new List<string>(groupTypes); 55 this.groupTypes = new List<string>(groupTypes.Select(g => g.ToString()));
56 this.itemTypes = new List<string>(itemTypes); 56 this.itemTypes = new List<string>(itemTypes.Select(i => i.ToString()));
57 57
58 this.items = new ItemCollection(); 58 this.items = new ItemCollection();
59 this.loaded = false; 59 this.loaded = false;
@@ -65,17 +65,18 @@ namespace WixToolset.Core.Link
65 /// <param name="parentType">The group type for the parent group to flatten.</param> 65 /// <param name="parentType">The group type for the parent group to flatten.</param>
66 /// <param name="parentId">The identifier of the parent group to flatten.</param> 66 /// <param name="parentId">The identifier of the parent group to flatten.</param>
67 /// <param name="removeUsedRows">Whether to remove used group rows before returning.</param> 67 /// <param name="removeUsedRows">Whether to remove used group rows before returning.</param>
68 public void FlattenAndRewriteRows(string parentType, string parentId, bool removeUsedRows) 68 public void FlattenAndRewriteRows(ComplexReferenceChildType parentType, string parentId, bool removeUsedRows)
69 { 69 {
70 Debug.Assert(this.groupTypes.Contains(parentType)); 70 var parentTypeString = parentType.ToString();
71 Debug.Assert(this.groupTypes.Contains(parentTypeString));
71 72
72 this.CreateOrderedList(parentType, parentId, out var orderedItems); 73 this.CreateOrderedList(parentTypeString, parentId, out var orderedItems);
73 if (this.encounteredError) 74 if (this.encounteredError)
74 { 75 {
75 return; 76 return;
76 } 77 }
77 78
78 this.CreateNewGroupRows(parentType, parentId, orderedItems); 79 this.CreateNewGroupRows(parentTypeString, parentId, orderedItems);
79 80
80 if (removeUsedRows) 81 if (removeUsedRows)
81 { 82 {
@@ -88,9 +89,10 @@ namespace WixToolset.Core.Link
88 /// </summary> 89 /// </summary>
89 /// <param name="parentType">The type of the parent group to flatten.</param> 90 /// <param name="parentType">The type of the parent group to flatten.</param>
90 /// <param name="removeUsedRows">Whether to remove used group rows before returning.</param> 91 /// <param name="removeUsedRows">Whether to remove used group rows before returning.</param>
91 public void FlattenAndRewriteGroups(string parentType, bool removeUsedRows) 92 public void FlattenAndRewriteGroups(ComplexReferenceParentType parentType, bool removeUsedRows)
92 { 93 {
93 Debug.Assert(this.groupTypes.Contains(parentType)); 94 var parentTypeString = parentType.ToString();
95 Debug.Assert(this.groupTypes.Contains(parentTypeString));
94 96
95 this.LoadFlattenOrderGroups(); 97 this.LoadFlattenOrderGroups();
96 if (this.encounteredError) 98 if (this.encounteredError)
@@ -100,10 +102,9 @@ namespace WixToolset.Core.Link
100 102
101 foreach (Item item in this.items) 103 foreach (Item item in this.items)
102 { 104 {
103 if (parentType == item.Type) 105 if (parentTypeString == item.Type)
104 { 106 {
105 List<Item> orderedItems; 107 this.CreateOrderedList(item.Type, item.Id, out var orderedItems);
106 this.CreateOrderedList(item.Type, item.Id, out orderedItems);
107 this.CreateNewGroupRows(item.Type, item.Id, orderedItems); 108 this.CreateNewGroupRows(item.Type, item.Id, orderedItems);
108 } 109 }
109 } 110 }
@@ -131,8 +132,7 @@ namespace WixToolset.Core.Link
131 return; 132 return;
132 } 133 }
133 134
134 Item parentItem; 135 if (!this.items.TryGetValue(parentType, parentId, out var parentItem))
135 if (!this.items.TryGetValue(parentType, parentId, out parentItem))
136 { 136 {
137 this.messageHandler.Write(ErrorMessages.IdentifierNotFound(parentType, parentId)); 137 this.messageHandler.Write(ErrorMessages.IdentifierNotFound(parentType, parentId));
138 return; 138 return;
@@ -360,9 +360,9 @@ namespace WixToolset.Core.Link
360 360
361 foreach (var row in this.EntrySection.Tuples.OfType<WixOrderingTuple>()) 361 foreach (var row in this.EntrySection.Tuples.OfType<WixOrderingTuple>())
362 { 362 {
363 var rowItemType = row.ItemType; 363 var rowItemType = row.ItemType.ToString();
364 var rowItemName = row.ItemId_; 364 var rowItemName = row.ItemId_;
365 var rowDependsOnType = row.DependsOnType; 365 var rowDependsOnType = row.DependsOnType.ToString();
366 var rowDependsOnName = row.DependsOnId_; 366 var rowDependsOnName = row.DependsOnId_;
367 367
368 // If this row specifies some other (unknown) type in either 368 // If this row specifies some other (unknown) type in either
@@ -510,8 +510,8 @@ namespace WixToolset.Core.Link
510 /// ordering dependencies.</remarks> 510 /// ordering dependencies.</remarks>
511 internal class Item 511 internal class Item
512 { 512 {
513 private ItemCollection afterItems; 513 private readonly ItemCollection afterItems;
514 private ItemCollection beforeItems; // for checking for circular references 514 private readonly ItemCollection beforeItems; // for checking for circular references
515 private bool flattenedAfterItems; 515 private bool flattenedAfterItems;
516 516
517 public Item(IntermediateTuple row, string type, string id) 517 public Item(IntermediateTuple row, string type, string id)
@@ -522,9 +522,9 @@ namespace WixToolset.Core.Link
522 522
523 this.Key = ItemCollection.CreateKeyFromTypeId(type, id); 523 this.Key = ItemCollection.CreateKeyFromTypeId(type, id);
524 524
525 afterItems = new ItemCollection(); 525 this.afterItems = new ItemCollection();
526 beforeItems = new ItemCollection(); 526 this.beforeItems = new ItemCollection();
527 flattenedAfterItems = false; 527 this.flattenedAfterItems = false;
528 } 528 }
529 529
530 public IntermediateTuple Row { get; private set; } 530 public IntermediateTuple Row { get; private set; }
@@ -540,8 +540,7 @@ namespace WixToolset.Core.Link
540 } 540 }
541#endif // DEBUG 541#endif // DEBUG
542 542
543 private ItemCollection childItems = new ItemCollection(); 543 public ItemCollection ChildItems { get; } = new ItemCollection();
544 public ItemCollection ChildItems { get { return childItems; } }
545 544
546 /// <summary> 545 /// <summary>
547 /// Removes any nested groups under this item and replaces 546 /// Removes any nested groups under this item and replaces
@@ -614,7 +613,7 @@ namespace WixToolset.Core.Link
614 { 613 {
615 if (this.ShouldItemPropagateChildOrdering()) 614 if (this.ShouldItemPropagateChildOrdering())
616 { 615 {
617 foreach (Item childItem in this.childItems) 616 foreach (Item childItem in this.ChildItems)
618 { 617 {
619 childItem.AddAfter(this.afterItems, messageHandler); 618 childItem.AddAfter(this.afterItems, messageHandler);
620 } 619 }
@@ -667,9 +666,9 @@ namespace WixToolset.Core.Link
667 // first payload to be the entrypoint. 666 // first payload to be the entrypoint.
668 private bool ShouldItemPropagateChildOrdering() 667 private bool ShouldItemPropagateChildOrdering()
669 { 668 {
670 if (String.Equals("Package", this.Type, StringComparison.Ordinal) || 669 if (String.Equals(nameof(ComplexReferenceChildType.Package), this.Type, StringComparison.Ordinal) ||
671 (String.Equals("Container", this.Type, StringComparison.Ordinal) && 670 (String.Equals(nameof(ComplexReferenceParentType.Container), this.Type, StringComparison.Ordinal) &&
672 !String.Equals(Compiler.BurnUXContainerId, this.Id, StringComparison.Ordinal))) 671 !String.Equals(Compiler.BurnUXContainerId.Id, this.Id, StringComparison.Ordinal)))
673 { 672 {
674 return false; 673 return false;
675 } 674 }