aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-26 12:59:03 -0700
committerRob Mensching <rob@firegiant.com>2021-04-02 14:58:00 -0700
commit9cca339473d77c7036035f949239f5231c325968 (patch)
tree342399ad52d1eb8102be17c71a12242c566fca25 /src
parent67bcf306aa020c5480b6dd28eab5db3d49264585 (diff)
downloadwix-9cca339473d77c7036035f949239f5231c325968.tar.gz
wix-9cca339473d77c7036035f949239f5231c325968.tar.bz2
wix-9cca339473d77c7036035f949239f5231c325968.zip
Integrate the IntermediateSection and IntermediateSymbol mutable changes
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs2
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs32
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs27
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs17
-rw-r--r--src/WixToolset.Core/CompilerCore.cs3
-rw-r--r--src/WixToolset.Core/Librarian.cs2
-rw-r--r--src/WixToolset.Core/Link/WixGroupingOrdering.cs66
-rw-r--r--src/WixToolset.Core/Linker.cs13
8 files changed, 69 insertions, 93 deletions
diff --git a/src/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs b/src/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
index f16ac707..19fd7619 100644
--- a/src/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
+++ b/src/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
@@ -65,7 +65,7 @@ namespace WixToolset.Core.Burn.Bundles
65 // If we used the default boundary, ensure the symbol is added to the section. 65 // If we used the default boundary, ensure the symbol is added to the section.
66 if (pendingRollbackBoundary.Id.Id == DefaultBoundaryId) 66 if (pendingRollbackBoundary.Id.Id == DefaultBoundaryId)
67 { 67 {
68 this.Section.Symbols.Add(pendingRollbackBoundary); 68 this.Section.AddSymbol(pendingRollbackBoundary);
69 } 69 }
70 70
71 if (insideMsiTransaction && !warnedMsiTransaction) 71 if (insideMsiTransaction && !warnedMsiTransaction)
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
index d7faa382..cfa84629 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
@@ -86,25 +86,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind
86 86
87 this.UncompressedFileFacades = Array.Empty<IFileFacade>(); 87 this.UncompressedFileFacades = Array.Empty<IFileFacade>();
88 } 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 }
101 else 89 else
102 { 90 {
103 var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>(); 91 var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>();
104
105 var uncompressedFiles = new List<IFileFacade>(); 92 var uncompressedFiles = new List<IFileFacade>();
106 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 }
108 102
109 this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value); 103 this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value);
110 104
@@ -115,7 +109,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
115 /// <summary> 109 /// <summary>
116 /// Assign files to cabinets based on MediaTemplate authoring. 110 /// Assign files to cabinets based on MediaTemplate authoring.
117 /// </summary> 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)
119 { 113 {
120 const int MaxCabIndex = 999; 114 const int MaxCabIndex = 999;
121 115
@@ -126,13 +120,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
126 120
127 MediaSymbol currentMediaRow = null; 121 MediaSymbol currentMediaRow = null;
128 122
129 var mediaTemplateTable = this.Section.Symbols.OfType<WixMediaTemplateSymbol>();
130
131 // Remove all previous media symbols since they will be replaced with 123 // Remove all previous media symbols since they will be replaced with
132 // media template. 124 // media template.
133 foreach (var mediaSymbol in mediaTable) 125 foreach (var mediaSymbol in mediaSymbols)
134 { 126 {
135 this.Section.Symbols.Remove(mediaSymbol); 127 this.Section.RemoveSymbol(mediaSymbol);
136 } 128 }
137 129
138 // Auto assign files to cabinets based on maximum uncompressed media size 130 // Auto assign files to cabinets based on maximum uncompressed media size
@@ -218,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
218 } 210 }
219 211
220 // If there are uncompressed files and no MediaRow, create a default one. 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)
222 { 214 {
223 var defaultMediaRow = this.Section.AddSymbol(new MediaSymbol(null, new Identifier(AccessModifier.Section, 1)) 215 var defaultMediaRow = this.Section.AddSymbol(new MediaSymbol(null, new Identifier(AccessModifier.Section, 1))
224 { 216 {
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
index 6d802d98..5f8df92c 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
@@ -241,23 +241,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind
241 241
242 foreach (var section in this.Intermediate.Sections) 242 foreach (var section in this.Intermediate.Sections)
243 { 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())
245 { 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)
247 { 256 {
248 // Remove all summary information from the symbols and remember those that 257 result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo);
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 }
261 } 258 }
262 } 259 }
263 } 260 }
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
index 5e72ec5c..94fa0a6a 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
@@ -173,21 +173,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
173 } 173 }
174 174
175 // Remove all existing WixActionSymbols from the section then add the 175 // Remove all existing WixActionSymbols from the section then add the
176 // scheduled actions back to the section. Note: we add the indices in 176 // scheduled actions back to the section.
177 // reverse order to make it easy to remove them from the list later. 177 var removeActionSymbols = this.Section.Symbols.Where(s => s.Definition.Type == SymbolDefinitionType.WixAction).ToList();
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 }
187 178
188 foreach (var removeIndex in removeIndices) 179 foreach (var removeSymbol in removeActionSymbols)
189 { 180 {
190 this.Section.Symbols.RemoveAt(removeIndex); 181 this.Section.RemoveSymbol(removeSymbol);
191 } 182 }
192 183
193 foreach (var action in scheduledActionSymbols) 184 foreach (var action in scheduledActionSymbols)
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs
index d737b359..0bc63d79 100644
--- a/src/WixToolset.Core/CompilerCore.cs
+++ b/src/WixToolset.Core/CompilerCore.cs
@@ -1059,8 +1059,7 @@ namespace WixToolset.Core
1059 /// <returns>New section.</returns> 1059 /// <returns>New section.</returns>
1060 internal IntermediateSection CreateSection(string id, SectionType type, int codepage, string compilationId) 1060 internal IntermediateSection CreateSection(string id, SectionType type, int codepage, string compilationId)
1061 { 1061 {
1062 var section = new IntermediateSection(id, type, codepage); 1062 var section = new IntermediateSection(id, type, codepage, compilationId);
1063 section.CompilationId = compilationId;
1064 1063
1065 this.intermediate.Sections.Add(section); 1064 this.intermediate.Sections.Add(section);
1066 1065
diff --git a/src/WixToolset.Core/Librarian.cs b/src/WixToolset.Core/Librarian.cs
index 059a478b..1dd1b44d 100644
--- a/src/WixToolset.Core/Librarian.cs
+++ b/src/WixToolset.Core/Librarian.cs
@@ -60,7 +60,7 @@ namespace WixToolset.Core
60 60
61 foreach (var section in sections) 61 foreach (var section in sections)
62 { 62 {
63 section.LibraryId = context.LibraryId; 63 section.AssignToLibrary(context.LibraryId);
64 } 64 }
65 65
66 library = new Intermediate(context.LibraryId, IntermediateLevels.Compiled, sections, localizationsByCulture); 66 library = new Intermediate(context.LibraryId, IntermediateLevels.Compiled, sections, localizationsByCulture);
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
diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs
index a6d43715..320f7d1f 100644
--- a/src/WixToolset.Core/Linker.cs
+++ b/src/WixToolset.Core/Linker.cs
@@ -585,13 +585,15 @@ namespace WixToolset.Core
585 // now and after processing added back in Step 3 below. 585 // now and after processing added back in Step 3 below.
586 foreach (var section in sections) 586 foreach (var section in sections)
587 { 587 {
588 var removeSymbols = new List<IntermediateSymbol>();
589
588 // Count down because we'll sometimes remove items from the list. 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)
590 { 592 {
591 // Only process the "grouping parents" such as FeatureGroup, ComponentGroup, Feature, 593 // Only process the "grouping parents" such as FeatureGroup, ComponentGroup, Feature,
592 // and Module. Non-grouping complex references are simple and 594 // and Module. Non-grouping complex references are simple and
593 // resolved during normal complex reference resolutions. 595 // resolved during normal complex reference resolutions.
594 if (section.Symbols[i] is WixComplexReferenceSymbol wixComplexReferenceRow && 596 if (symbol is WixComplexReferenceSymbol wixComplexReferenceRow &&
595 (ComplexReferenceParentType.FeatureGroup == wixComplexReferenceRow.ParentType || 597 (ComplexReferenceParentType.FeatureGroup == wixComplexReferenceRow.ParentType ||
596 ComplexReferenceParentType.ComponentGroup == wixComplexReferenceRow.ParentType || 598 ComplexReferenceParentType.ComponentGroup == wixComplexReferenceRow.ParentType ||
597 ComplexReferenceParentType.Feature == wixComplexReferenceRow.ParentType || 599 ComplexReferenceParentType.Feature == wixComplexReferenceRow.ParentType ||
@@ -611,7 +613,7 @@ namespace WixToolset.Core
611 } 613 }
612 614
613 childrenComplexRefs.Add(wixComplexReferenceRow); 615 childrenComplexRefs.Add(wixComplexReferenceRow);
614 section.Symbols.RemoveAt(i); 616 removeSymbols.Add(wixComplexReferenceRow);
615 617
616 // Remember the mapping from set of complex references with a common 618 // Remember the mapping from set of complex references with a common
617 // parent to their section. We'll need this to add them back to the 619 // parent to their section. We'll need this to add them back to the
@@ -635,6 +637,11 @@ namespace WixToolset.Core
635 } 637 }
636 } 638 }
637 } 639 }
640
641 foreach (var removeSymbol in removeSymbols)
642 {
643 section.RemoveSymbol(removeSymbol);
644 }
638 } 645 }
639 646
640 Debug.Assert(parentGroups.Count == parentGroupsSections.Count); 647 Debug.Assert(parentGroups.Count == parentGroupsSections.Count);