diff options
Diffstat (limited to 'src/WixToolset.Core/Link/WixGroupingOrdering.cs')
-rw-r--r-- | src/WixToolset.Core/Link/WixGroupingOrdering.cs | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/WixToolset.Core/Link/WixGroupingOrdering.cs b/src/WixToolset.Core/Link/WixGroupingOrdering.cs index a8044a0c..99220900 100644 --- a/src/WixToolset.Core/Link/WixGroupingOrdering.cs +++ b/src/WixToolset.Core/Link/WixGroupingOrdering.cs | |||
@@ -23,7 +23,7 @@ namespace WixToolset.Core.Link | |||
23 | private List<string> groupTypes; | 23 | private List<string> groupTypes; |
24 | private List<string> itemTypes; | 24 | private List<string> itemTypes; |
25 | private ItemCollection items; | 25 | private ItemCollection items; |
26 | private readonly List<int> rowsUsed; | 26 | private readonly List<IntermediateSymbol> symbolsUsed; |
27 | private bool loaded; | 27 | private bool loaded; |
28 | 28 | ||
29 | /// <summary> | 29 | /// <summary> |
@@ -36,7 +36,7 @@ namespace WixToolset.Core.Link | |||
36 | this.EntrySection = entrySections; | 36 | this.EntrySection = entrySections; |
37 | this.Messaging = messageHandler; | 37 | this.Messaging = messageHandler; |
38 | 38 | ||
39 | this.rowsUsed = new List<int>(); | 39 | this.symbolsUsed = new List<IntermediateSymbol>(); |
40 | this.loaded = false; | 40 | this.loaded = false; |
41 | } | 41 | } |
42 | 42 | ||
@@ -144,16 +144,9 @@ namespace WixToolset.Core.Link | |||
144 | /// </summary> | 144 | /// </summary> |
145 | public void RemoveUsedGroupRows() | 145 | public void RemoveUsedGroupRows() |
146 | { | 146 | { |
147 | var sortedIndexes = this.rowsUsed.Distinct().OrderByDescending(i => i).ToList(); | 147 | foreach (var symbol in this.symbolsUsed) |
148 | |||
149 | //Table wixGroupTable = this.output.Tables["WixGroup"]; | ||
150 | //Debug.Assert(null != wixGroupTable); | ||
151 | //Debug.Assert(sortedIndexes[0] < wixGroupTable.Rows.Count); | ||
152 | |||
153 | foreach (int rowIndex in sortedIndexes) | ||
154 | { | 148 | { |
155 | //wixGroupTable.Rows.RemoveAt(rowIndex); | 149 | this.EntrySection.RemoveSymbol(symbol); |
156 | this.EntrySection.Symbols.RemoveAt(rowIndex); | ||
157 | } | 150 | } |
158 | } | 151 | } |
159 | 152 | ||
@@ -236,39 +229,36 @@ namespace WixToolset.Core.Link | |||
236 | //} | 229 | //} |
237 | 230 | ||
238 | // Collect all of the groups | 231 | // Collect all of the groups |
239 | for (int rowIndex = 0; rowIndex < this.EntrySection.Symbols.Count; ++rowIndex) | 232 | foreach (var symbol in this.EntrySection.Symbols.OfType<WixGroupSymbol>()) |
240 | { | 233 | { |
241 | if (this.EntrySection.Symbols[rowIndex] is WixGroupSymbol row) | 234 | var rowParentName = symbol.ParentId; |
235 | var rowParentType = symbol.ParentType.ToString(); | ||
236 | var rowChildName = symbol.ChildId; | ||
237 | var rowChildType = symbol.ChildType.ToString(); | ||
238 | |||
239 | // If this row specifies a parent or child type that's not in our | ||
240 | // lists, we assume it's not a row that we're concerned about. | ||
241 | if (!this.groupTypes.Contains(rowParentType) || | ||
242 | !this.itemTypes.Contains(rowChildType)) | ||
242 | { | 243 | { |
243 | var rowParentName = row.ParentId; | 244 | continue; |
244 | var rowParentType = row.ParentType.ToString(); | 245 | } |
245 | var rowChildName = row.ChildId; | ||
246 | var rowChildType = row.ChildType.ToString(); | ||
247 | |||
248 | // If this row specifies a parent or child type that's not in our | ||
249 | // lists, we assume it's not a row that we're concerned about. | ||
250 | if (!this.groupTypes.Contains(rowParentType) || | ||
251 | !this.itemTypes.Contains(rowChildType)) | ||
252 | { | ||
253 | continue; | ||
254 | } | ||
255 | 246 | ||
256 | this.rowsUsed.Add(rowIndex); | 247 | this.symbolsUsed.Add(symbol); |
257 | 248 | ||
258 | if (!this.items.TryGetValue(rowParentType, rowParentName, out var parentItem)) | 249 | if (!this.items.TryGetValue(rowParentType, rowParentName, out var parentItem)) |
259 | { | 250 | { |
260 | parentItem = new Item(row, rowParentType, rowParentName); | 251 | parentItem = new Item(symbol, rowParentType, rowParentName); |
261 | this.items.Add(parentItem); | 252 | this.items.Add(parentItem); |
262 | } | 253 | } |
263 | |||
264 | if (!this.items.TryGetValue(rowChildType, rowChildName, out var childItem)) | ||
265 | { | ||
266 | childItem = new Item(row, rowChildType, rowChildName); | ||
267 | this.items.Add(childItem); | ||
268 | } | ||
269 | 254 | ||
270 | parentItem.ChildItems.Add(childItem); | 255 | if (!this.items.TryGetValue(rowChildType, rowChildName, out var childItem)) |
256 | { | ||
257 | childItem = new Item(symbol, rowChildType, rowChildName); | ||
258 | this.items.Add(childItem); | ||
271 | } | 259 | } |
260 | |||
261 | parentItem.ChildItems.Add(childItem); | ||
272 | } | 262 | } |
273 | } | 263 | } |
274 | 264 | ||