Integrate the IntermediateSection and IntermediateSymbol mutable changes
Rob Mensching committed
Mar 26, 2021 at 12:59 UTC
9cca339473d77c7036035f949239f5231c325968
8 files changed
+69
-93
src/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
+1
-1
@@ -65,7 +65,7 @@ namespace WixToolset.Core.Burn.Bundles
65
// If we used the default boundary, ensure the symbol is added to the section.
66
if (pendingRollbackBoundary.Id.Id == DefaultBoundaryId)
67
{
68
- this.Section.Symbols.Add(pendingRollbackBoundary);
68
+ this.Section.AddSymbol(pendingRollbackBoundary);
69
}
70
71
if (insideMsiTransaction && !warnedMsiTransaction)
src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
+12
-20
@@ -86,25 +86,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind
86
87
this.UncompressedFileFacades = Array.Empty<IFileFacade>();
88
}
89
- else if (mediaTemplateSymbols.Count == 0)
90
- {
91
- var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>();
92
-
93
- var uncompressedFiles = new List<IFileFacade>();
94
-
95
- this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles);
96
-
97
- this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value);
98
-
99
- this.UncompressedFileFacades = uncompressedFiles;
100
- }
89
else
90
{
91
var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>();
104
-
92
var uncompressedFiles = new List<IFileFacade>();
93
107
- this.AutoAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles);
94
+ if (mediaTemplateSymbols.Count > 0)
95
+ {
96
+ this.AutoAssignFiles(mediaTemplateSymbols, mediaSymbols, filesByCabinetMedia, uncompressedFiles);
97
+ }
98
+ else
99
+ {
100
+ this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles);
101
+ }
102
103
this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value);
104
@@ -115,7 +109,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
109
/// <summary>
110
/// Assign files to cabinets based on MediaTemplate authoring.
111
/// </summary>
118
- private void AutoAssignFiles(List<MediaSymbol> mediaTable, Dictionary<MediaSymbol, List<IFileFacade>> filesByCabinetMedia, List<IFileFacade> uncompressedFiles)
112
+ private void AutoAssignFiles(List<WixMediaTemplateSymbol> mediaTemplateTable, List<MediaSymbol> mediaSymbols, Dictionary<MediaSymbol, List<IFileFacade>> filesByCabinetMedia, List<IFileFacade> uncompressedFiles)
113
{
114
const int MaxCabIndex = 999;
115
@@ -126,13 +120,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
120
121
MediaSymbol currentMediaRow = null;
122
129
- var mediaTemplateTable = this.Section.Symbols.OfType<WixMediaTemplateSymbol>();
130
-
123
// Remove all previous media symbols since they will be replaced with
124
// media template.
133
- foreach (var mediaSymbol in mediaTable)
125
+ foreach (var mediaSymbol in mediaSymbols)
126
{
135
- this.Section.Symbols.Remove(mediaSymbol);
127
+ this.Section.RemoveSymbol(mediaSymbol);
128
}
129
130
// Auto assign files to cabinets based on maximum uncompressed media size
@@ -218,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
210
}
211
212
// If there are uncompressed files and no MediaRow, create a default one.
221
- if (uncompressedFiles.Count > 0 && !this.Section.Symbols.OfType<MediaSymbol>().Any())
213
+ if (uncompressedFiles.Count > 0 && mediaSymbolsByDiskId.Count == 0)
214
{
215
var defaultMediaRow = this.Section.AddSymbol(new MediaSymbol(null, new Identifier(AccessModifier.Section, 1))
216
{
src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
+12
-15
@@ -241,23 +241,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind
241
242
foreach (var section in this.Intermediate.Sections)
243
{
244
- for (var i = section.Symbols.Count - 1; i >= 0; i--)
244
+ // Remove all summary information from the symbols and remember those that
245
+ // are not calculated or reserved.
246
+ foreach (var patchSummaryInfo in section.Symbols.OfType<SummaryInformationSymbol>().ToList())
247
{
246
- if (section.Symbols[i] is SummaryInformationSymbol patchSummaryInfo)
248
+ section.RemoveSymbol(patchSummaryInfo);
249
+
250
+ if (patchSummaryInfo.PropertyId != SummaryInformationType.PatchProductCodes &&
251
+ patchSummaryInfo.PropertyId != SummaryInformationType.PatchCode &&
252
+ patchSummaryInfo.PropertyId != SummaryInformationType.PatchInstallerRequirement &&
253
+ patchSummaryInfo.PropertyId != SummaryInformationType.Reserved11 &&
254
+ patchSummaryInfo.PropertyId != SummaryInformationType.Reserved14 &&
255
+ patchSummaryInfo.PropertyId != SummaryInformationType.Reserved16)
256
{
248
- // Remove all summary information from the symbols and remember those that
249
- // are not calculated or reserved.
250
- section.Symbols.RemoveAt(i);
251
-
252
- if (patchSummaryInfo.PropertyId != SummaryInformationType.PatchProductCodes &&
253
- patchSummaryInfo.PropertyId != SummaryInformationType.PatchCode &&
254
- patchSummaryInfo.PropertyId != SummaryInformationType.PatchInstallerRequirement &&
255
- patchSummaryInfo.PropertyId != SummaryInformationType.Reserved11 &&
256
- patchSummaryInfo.PropertyId != SummaryInformationType.Reserved14 &&
257
- patchSummaryInfo.PropertyId != SummaryInformationType.Reserved16)
258
- {
259
- result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo);
260
- }
257
+ result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo);
258
}
259
}
260
}
src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+4
-13
@@ -173,21 +173,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
173
}
174
175
// Remove all existing WixActionSymbols from the section then add the
176
- // scheduled actions back to the section. Note: we add the indices in
177
- // reverse order to make it easy to remove them from the list later.
178
- var removeIndices = new List<int>();
179
- for (var i = this.Section.Symbols.Count - 1; i >= 0; --i)
180
- {
181
- var symbol = this.Section.Symbols[i];
182
- if (symbol.Definition.Type == SymbolDefinitionType.WixAction)
183
- {
184
- removeIndices.Add(i);
185
- }
186
- }
176
+ // scheduled actions back to the section.
177
+ var removeActionSymbols = this.Section.Symbols.Where(s => s.Definition.Type == SymbolDefinitionType.WixAction).ToList();
178
188
- foreach (var removeIndex in removeIndices)
179
+ foreach (var removeSymbol in removeActionSymbols)
180
{
190
- this.Section.Symbols.RemoveAt(removeIndex);
181
+ this.Section.RemoveSymbol(removeSymbol);
182
}
183
184
foreach (var action in scheduledActionSymbols)
src/WixToolset.Core/CompilerCore.cs
+1
-2
@@ -1059,8 +1059,7 @@ namespace WixToolset.Core
1059
/// <returns>New section.</returns>
1060
internal IntermediateSection CreateSection(string id, SectionType type, int codepage, string compilationId)
1061
{
1062
- var section = new IntermediateSection(id, type, codepage);
1063
- section.CompilationId = compilationId;
1062
+ var section = new IntermediateSection(id, type, codepage, compilationId);
1063
1064
this.intermediate.Sections.Add(section);
1065
src/WixToolset.Core/Librarian.cs
+1
-1
@@ -60,7 +60,7 @@ namespace WixToolset.Core
60
61
foreach (var section in sections)
62
{
63
- section.LibraryId = context.LibraryId;
63
+ section.AssignToLibrary(context.LibraryId);
64
}
65
66
library = new Intermediate(context.LibraryId, IntermediateLevels.Compiled, sections, localizationsByCulture);
src/WixToolset.Core/Link/WixGroupingOrdering.cs
+28
-38
@@ -23,7 +23,7 @@ namespace WixToolset.Core.Link
23
private List<string> groupTypes;
24
private List<string> itemTypes;
25
private ItemCollection items;
26
- private readonly List<int> rowsUsed;
26
+ private readonly List<IntermediateSymbol> symbolsUsed;
27
private bool loaded;
28
29
/// <summary>
@@ -36,7 +36,7 @@ namespace WixToolset.Core.Link
36
this.EntrySection = entrySections;
37
this.Messaging = messageHandler;
38
39
- this.rowsUsed = new List<int>();
39
+ this.symbolsUsed = new List<IntermediateSymbol>();
40
this.loaded = false;
41
}
42
@@ -144,16 +144,9 @@ namespace WixToolset.Core.Link
144
/// </summary>
145
public void RemoveUsedGroupRows()
146
{
147
- var sortedIndexes = this.rowsUsed.Distinct().OrderByDescending(i => i).ToList();
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)
147
+ foreach (var symbol in this.symbolsUsed)
148
{
155
- //wixGroupTable.Rows.RemoveAt(rowIndex);
156
- this.EntrySection.Symbols.RemoveAt(rowIndex);
149
+ this.EntrySection.RemoveSymbol(symbol);
150
}
151
}
152
@@ -236,39 +229,36 @@ namespace WixToolset.Core.Link
229
//}
230
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>())
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))
243
{
243
- var rowParentName = row.ParentId;
244
- var rowParentType = row.ParentType.ToString();
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
- }
244
+ continue;
245
+ }
246
256
- this.rowsUsed.Add(rowIndex);
247
+ this.symbolsUsed.Add(symbol);
248
258
- if (!this.items.TryGetValue(rowParentType, rowParentName, out var parentItem))
259
- {
260
- parentItem = new Item(row, rowParentType, rowParentName);
261
- this.items.Add(parentItem);
262
- }
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
- }
249
+ if (!this.items.TryGetValue(rowParentType, rowParentName, out var parentItem))
250
+ {
251
+ parentItem = new Item(symbol, rowParentType, rowParentName);
252
+ this.items.Add(parentItem);
253
+ }
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);
259
}
260
+
261
+ parentItem.ChildItems.Add(childItem);
262
}
263
}
264
src/WixToolset.Core/Linker.cs
+10
-3
@@ -585,13 +585,15 @@ namespace WixToolset.Core
585
// now and after processing added back in Step 3 below.
586
foreach (var section in sections)
587
{
588
+ var removeSymbols = new List<IntermediateSymbol>();
589
+
590
// Count down because we'll sometimes remove items from the list.
589
- for (var i = section.Symbols.Count - 1; i >= 0; --i)
591
+ foreach (var symbol in section.Symbols)
592
{
593
// Only process the "grouping parents" such as FeatureGroup, ComponentGroup, Feature,
594
// and Module. Non-grouping complex references are simple and
595
// resolved during normal complex reference resolutions.
594
- if (section.Symbols[i] is WixComplexReferenceSymbol wixComplexReferenceRow &&
596
+ if (symbol is WixComplexReferenceSymbol wixComplexReferenceRow &&
597
(ComplexReferenceParentType.FeatureGroup == wixComplexReferenceRow.ParentType ||
598
ComplexReferenceParentType.ComponentGroup == wixComplexReferenceRow.ParentType ||
599
ComplexReferenceParentType.Feature == wixComplexReferenceRow.ParentType ||
@@ -611,7 +613,7 @@ namespace WixToolset.Core
613
}
614
615
childrenComplexRefs.Add(wixComplexReferenceRow);
614
- section.Symbols.RemoveAt(i);
616
+ removeSymbols.Add(wixComplexReferenceRow);
617
618
// Remember the mapping from set of complex references with a common
619
// parent to their section. We'll need this to add them back to the
@@ -635,6 +637,11 @@ namespace WixToolset.Core
637
}
638
}
639
}
640
+
641
+ foreach (var removeSymbol in removeSymbols)
642
+ {
643
+ section.RemoveSymbol(removeSymbol);
644
+ }
645
}
646
647
Debug.Assert(parentGroups.Count == parentGroupsSections.Count);