From 9cca339473d77c7036035f949239f5231c325968 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 26 Mar 2021 12:59:03 -0700 Subject: Integrate the IntermediateSection and IntermediateSymbol mutable changes --- .../Bind/AssignMediaCommand.cs | 32 ++++++++-------------- .../Bind/AttachPatchTransformsCommand.cs | 27 ++++++++---------- .../Bind/SequenceActionsCommand.cs | 17 +++--------- 3 files changed, 28 insertions(+), 48 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller') 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 this.UncompressedFileFacades = Array.Empty(); } - else if (mediaTemplateSymbols.Count == 0) - { - var filesByCabinetMedia = new Dictionary>(); - - var uncompressedFiles = new List(); - - this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); - - this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable)kvp.Value); - - this.UncompressedFileFacades = uncompressedFiles; - } else { var filesByCabinetMedia = new Dictionary>(); - var uncompressedFiles = new List(); - this.AutoAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); + if (mediaTemplateSymbols.Count > 0) + { + this.AutoAssignFiles(mediaTemplateSymbols, mediaSymbols, filesByCabinetMedia, uncompressedFiles); + } + else + { + this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); + } this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable)kvp.Value); @@ -115,7 +109,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Assign files to cabinets based on MediaTemplate authoring. /// - private void AutoAssignFiles(List mediaTable, Dictionary> filesByCabinetMedia, List uncompressedFiles) + private void AutoAssignFiles(List mediaTemplateTable, List mediaSymbols, Dictionary> filesByCabinetMedia, List uncompressedFiles) { const int MaxCabIndex = 999; @@ -126,13 +120,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind MediaSymbol currentMediaRow = null; - var mediaTemplateTable = this.Section.Symbols.OfType(); - // Remove all previous media symbols since they will be replaced with // media template. - foreach (var mediaSymbol in mediaTable) + foreach (var mediaSymbol in mediaSymbols) { - this.Section.Symbols.Remove(mediaSymbol); + this.Section.RemoveSymbol(mediaSymbol); } // Auto assign files to cabinets based on maximum uncompressed media size @@ -218,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // If there are uncompressed files and no MediaRow, create a default one. - if (uncompressedFiles.Count > 0 && !this.Section.Symbols.OfType().Any()) + if (uncompressedFiles.Count > 0 && mediaSymbolsByDiskId.Count == 0) { var defaultMediaRow = this.Section.AddSymbol(new MediaSymbol(null, new Identifier(AccessModifier.Section, 1)) { 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 foreach (var section in this.Intermediate.Sections) { - for (var i = section.Symbols.Count - 1; i >= 0; i--) + // Remove all summary information from the symbols and remember those that + // are not calculated or reserved. + foreach (var patchSummaryInfo in section.Symbols.OfType().ToList()) { - if (section.Symbols[i] is SummaryInformationSymbol patchSummaryInfo) + section.RemoveSymbol(patchSummaryInfo); + + if (patchSummaryInfo.PropertyId != SummaryInformationType.PatchProductCodes && + patchSummaryInfo.PropertyId != SummaryInformationType.PatchCode && + patchSummaryInfo.PropertyId != SummaryInformationType.PatchInstallerRequirement && + patchSummaryInfo.PropertyId != SummaryInformationType.Reserved11 && + patchSummaryInfo.PropertyId != SummaryInformationType.Reserved14 && + patchSummaryInfo.PropertyId != SummaryInformationType.Reserved16) { - // Remove all summary information from the symbols and remember those that - // are not calculated or reserved. - section.Symbols.RemoveAt(i); - - if (patchSummaryInfo.PropertyId != SummaryInformationType.PatchProductCodes && - patchSummaryInfo.PropertyId != SummaryInformationType.PatchCode && - patchSummaryInfo.PropertyId != SummaryInformationType.PatchInstallerRequirement && - patchSummaryInfo.PropertyId != SummaryInformationType.Reserved11 && - patchSummaryInfo.PropertyId != SummaryInformationType.Reserved14 && - patchSummaryInfo.PropertyId != SummaryInformationType.Reserved16) - { - result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo); - } + result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo); } } } 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 } // Remove all existing WixActionSymbols from the section then add the - // scheduled actions back to the section. Note: we add the indices in - // reverse order to make it easy to remove them from the list later. - var removeIndices = new List(); - for (var i = this.Section.Symbols.Count - 1; i >= 0; --i) - { - var symbol = this.Section.Symbols[i]; - if (symbol.Definition.Type == SymbolDefinitionType.WixAction) - { - removeIndices.Add(i); - } - } + // scheduled actions back to the section. + var removeActionSymbols = this.Section.Symbols.Where(s => s.Definition.Type == SymbolDefinitionType.WixAction).ToList(); - foreach (var removeIndex in removeIndices) + foreach (var removeSymbol in removeActionSymbols) { - this.Section.Symbols.RemoveAt(removeIndex); + this.Section.RemoveSymbol(removeSymbol); } foreach (var action in scheduledActionSymbols) -- cgit v1.2.3-55-g6feb