From c0f1332a0e18e9d506fe80c328548b001dcf93df Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 12 Jun 2020 12:55:28 -0700 Subject: Remove use of remaining WixXxxRows --- .../Bind/BindDatabaseCommand.cs | 6 +- .../Bind/CreateCabinetsCommand.cs | 89 ++++---- .../Bind/CreateOutputFromIRCommand.cs | 23 +- .../Bind/GenerateTransformCommand.cs | 2 + .../Decompile/Decompiler.cs | 237 ++++++++++----------- 5 files changed, 159 insertions(+), 198 deletions(-) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index b3f81212..6c2968ec 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -428,7 +428,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind { this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); - var command = new CreateCabinetsCommand(this.ServiceProvider, this.BackendHelper); + var mediaTemplate = section.Tuples.OfType().FirstOrDefault(); + + var command = new CreateCabinetsCommand(this.ServiceProvider, this.BackendHelper, mediaTemplate); command.CabbingThreadCount = this.CabbingThreadCount; command.CabCachePath = this.CabCachePath; command.DefaultCompressionLevel = this.DefaultCompressionLevel; @@ -438,7 +440,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.LayoutDirectory = layoutDirectory; command.Compressed = compressed; command.ModularizationSuffix = modularizationSuffix; - command.FileRowsByCabinet = filesByCabinetMedia; + command.FileFacadesByCabinet = filesByCabinetMedia; command.ResolveMedia = this.ResolveMedia; command.TableDefinitions = tableDefinitions; command.IntermediateFolder = this.IntermediateFolder; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index f2f9895d..de357e53 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -12,7 +12,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data; using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; - using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -33,7 +32,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private Dictionary lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence - public CreateCabinetsCommand(IWixToolsetServiceProvider serviceProvider, IBackendHelper backendHelper) + public CreateCabinetsCommand(IWixToolsetServiceProvider serviceProvider, IBackendHelper backendHelper, WixMediaTemplateTuple mediaTemplate) { this.fileTransfers = new List(); @@ -44,11 +43,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.ServiceProvider = serviceProvider; this.BackendHelper = backendHelper; + + this.MediaTemplate = mediaTemplate; } - public IWixToolsetServiceProvider ServiceProvider { get; } + private IWixToolsetServiceProvider ServiceProvider { get; } + + private IBackendHelper BackendHelper { get; } - public IBackendHelper BackendHelper { get; } + private WixMediaTemplateTuple MediaTemplate { get; } /// /// Sets the number of threads to use for cabinet creation. @@ -77,7 +80,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind public string ModularizationSuffix { private get; set; } - public Dictionary> FileRowsByCabinet { private get; set; } + public Dictionary> FileFacadesByCabinet { private get; set; } public Func ResolveMedia { private get; set; } @@ -90,7 +93,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// Output to generate image for. /// The directory in which the image should be layed out. /// Flag if source image should be compressed. - /// The uncompressed file rows. public void Execute() { this.lastCabinetAddedToMediaTable = new Dictionary(); @@ -109,7 +111,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind cabinetBuilder.MaximumCabinetSizeForLargeFileSplitting = maximumCabinetSizeForLargeFileSplitting; cabinetBuilder.MaximumUncompressedMediaSize = maximumUncompressedMediaSize; - foreach (var entry in this.FileRowsByCabinet) + foreach (var entry in this.FileFacadesByCabinet) { var mediaTuple = entry.Key; var files = entry.Value; @@ -175,28 +177,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Output for the current database. /// Directory to create cabinet in. - /// MediaRow containing information about the cabinet. + /// Media tuple containing information about the cabinet. /// Collection of files in this cabinet. /// created CabinetWorkItem object - private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable fileFacades) + private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaTuple, CompressionLevel compressionLevel, IEnumerable fileFacades) { CabinetWorkItem cabinetWorkItem = null; - string tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaRow.Cabinet); + var tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaTuple.Cabinet); // check for an empty cabinet if (!fileFacades.Any()) { // Remove the leading '#' from the embedded cabinet name to make the warning easier to understand - var cabinetName = mediaRow.Cabinet.TrimStart('#'); + var cabinetName = mediaTuple.Cabinet.TrimStart('#'); // If building a patch, remind them to run -p for torch. if (OutputType.Patch == output.Type) { - this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); + this.Messaging.Write(WarningMessages.EmptyCabinet(mediaTuple.SourceLineNumbers, cabinetName, true)); } else { - this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); + this.Messaging.Write(WarningMessages.EmptyCabinet(mediaTuple.SourceLineNumbers, cabinetName)); } } @@ -212,7 +214,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else // reuse the cabinet from the cabinet cache. { - this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); + this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaTuple.SourceLineNumbers, mediaTuple.Cabinet, resolvedCabinet.Path)); try { @@ -226,27 +228,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (Exception e) { - this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); + this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaTuple.SourceLineNumbers, resolvedCabinet.Path, e.Message)); } } - var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaRow.SourceLineNumbers); + var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaTuple.SourceLineNumbers); this.trackedFiles.Add(trackResolvedCabinet); - if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal)) + if (mediaTuple.Cabinet.StartsWith("#", StringComparison.Ordinal)) { var streamsTable = output.EnsureTable(this.TableDefinitions["_Streams"]); - var streamRow = streamsTable.CreateRow(mediaRow.SourceLineNumbers); - streamRow[0] = mediaRow.Cabinet.Substring(1); + var streamRow = streamsTable.CreateRow(mediaTuple.SourceLineNumbers); + streamRow[0] = mediaTuple.Cabinet.Substring(1); streamRow[1] = resolvedCabinet.Path; } else { - var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaRow.Cabinet), TrackedFileType.Final, mediaRow.SourceLineNumbers); + var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaTuple.Cabinet), TrackedFileType.Final, mediaTuple.SourceLineNumbers); this.trackedFiles.Add(trackDestination); - var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaRow.SourceLineNumbers); + var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaTuple.SourceLineNumbers); this.fileTransfers.Add(transfer); } @@ -417,36 +419,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Gets Compiler Values of MediaTemplate Attributes governing Maximum Cabinet Size after applying Environment Variable Overrides /// - /// Output to generate image for. - /// The indexed file rows. private void GetMediaTemplateAttributes(out int maxCabSizeForLargeFileSplitting, out int maxUncompressedMediaSize) { // Get Environment Variable Overrides for MediaTemplate Attributes governing Maximum Cabinet Size - string mcslfsString = Environment.GetEnvironmentVariable("WIX_MCSLFS"); - string mumsString = Environment.GetEnvironmentVariable("WIX_MUMS"); - int maxCabSizeForLargeFileInMB = 0; - int maxPreCompressedSizeInMB = 0; - ulong testOverFlow = 0; + var mcslfsString = Environment.GetEnvironmentVariable("WIX_MCSLFS"); + var mumsString = Environment.GetEnvironmentVariable("WIX_MUMS"); // Supply Compile MediaTemplate Attributes to Cabinet Builder - Table mediaTemplateTable = this.Output.Tables["WixMediaTemplate"]; - if (mediaTemplateTable != null) + if (this.MediaTemplate != null) { - WixMediaTemplateRow mediaTemplateRow = (WixMediaTemplateRow)mediaTemplateTable.Rows[0]; - // Get the Value for Max Cab Size for File Splitting + var maxCabSizeForLargeFileInMB = 0; try { // Override authored mcslfs value if environment variable is authored. - if (!String.IsNullOrEmpty(mcslfsString)) - { - maxCabSizeForLargeFileInMB = Int32.Parse(mcslfsString); - } - else - { - maxCabSizeForLargeFileInMB = mediaTemplateRow.MaximumCabinetSizeForLargeFileSplitting; - } - testOverFlow = (ulong)maxCabSizeForLargeFileInMB * 1024 * 1024; + maxCabSizeForLargeFileInMB = !String.IsNullOrEmpty(mcslfsString) ? Int32.Parse(mcslfsString) : this.MediaTemplate.MaximumCabinetSizeForLargeFileSplitting ?? MaxValueOfMaxCabSizeForLargeFileSplitting; + + var testOverFlow = (ulong)maxCabSizeForLargeFileInMB * 1024 * 1024; + maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; } catch (FormatException) { @@ -457,18 +447,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind throw new WixException(ErrorMessages.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); } + var maxPreCompressedSizeInMB = 0; try { // Override authored mums value if environment variable is authored. - if (!String.IsNullOrEmpty(mumsString)) - { - maxPreCompressedSizeInMB = Int32.Parse(mumsString); - } - else - { - maxPreCompressedSizeInMB = mediaTemplateRow.MaximumUncompressedMediaSize; - } - testOverFlow = (ulong)maxPreCompressedSizeInMB * 1024 * 1024; + maxPreCompressedSizeInMB = !String.IsNullOrEmpty(mumsString) ? Int32.Parse(mumsString) : this.MediaTemplate.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; + + var testOverFlow = (ulong)maxPreCompressedSizeInMB * 1024 * 1024; + maxUncompressedMediaSize = maxPreCompressedSizeInMB; } catch (FormatException) { @@ -478,9 +464,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind { throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); } - - maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; - maxUncompressedMediaSize = maxPreCompressedSizeInMB; } else { diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index 21c39423..448ed607 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs @@ -15,9 +15,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind internal class CreateOutputFromIRCommand { - private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB - private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) - public CreateOutputFromIRCommand(IMessaging messaging, IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable backendExtensions, IWindowsInstallerBackendHelper backendHelper) { this.Messaging = messaging; @@ -189,10 +186,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddWixActionTuple((WixActionTuple)tuple); break; - case TupleDefinitionType.WixMediaTemplate: - this.AddWixMediaTemplateTuple((WixMediaTemplateTuple)tuple); - break; - case TupleDefinitionType.WixCustomTableCell: this.IndexCustomTableCellTuple((WixCustomTableCellTuple)tuple, cellsByTableAndRowId); break; @@ -202,6 +195,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; // Tuples used internally and are not added to the output. + case TupleDefinitionType.WixBuildInfo: case TupleDefinitionType.WixComponentGroup: case TupleDefinitionType.WixComplexReference: case TupleDefinitionType.WixDeltaPatchFile: @@ -211,6 +205,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind case TupleDefinitionType.WixInstanceComponent: case TupleDefinitionType.WixInstanceTransforms: case TupleDefinitionType.WixFeatureModules: + case TupleDefinitionType.WixGroup: + case TupleDefinitionType.WixMediaTemplate: case TupleDefinitionType.WixMerge: case TupleDefinitionType.WixOrdering: case TupleDefinitionType.WixPatchBaseline: @@ -946,7 +942,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - bool after = (null == tuple.Before); + var after = (null == tuple.Before); row[2] = after ? tuple.After : tuple.Before; row[3] = after ? 1 : 0; } @@ -1052,17 +1048,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.Output.EnsureTable(tableDefinition); } - private void AddWixMediaTemplateTuple(WixMediaTemplateTuple tuple) - { - var row = (WixMediaTemplateRow)this.CreateRow(tuple, "WixMediaTemplate"); - row.CabinetTemplate = tuple.CabinetTemplate; - row.CompressionLevel = tuple.CompressionLevel; - row.DiskPrompt = tuple.DiskPrompt; - row.VolumeLabel = tuple.VolumeLabel; - row.MaximumUncompressedMediaSize = tuple.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; - row.MaximumCabinetSizeForLargeFileSplitting = tuple.MaximumCabinetSizeForLargeFileSplitting ?? MaxValueOfMaxCabSizeForLargeFileSplitting; - } - private bool AddTupleFromExtension(IntermediateTuple tuple) { foreach (var extension in this.BackendExtensions) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs index 201a890c..fc713954 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs @@ -160,6 +160,7 @@ namespace WixToolset.Core.WindowsInstaller { if (index.TryGetValue(primaryKey, out var collisionRow)) { +#if TODO_PATCH // This case doesn't seem like it can happen any longer. // Overriding WixActionRows have a primary key defined and take precedence in the index. if (row is WixActionRow actionRow) { @@ -176,6 +177,7 @@ namespace WixToolset.Core.WindowsInstaller // If we got this far, the row does not need to be indexed. return; } +#endif if (this.ShowPedanticMessages) { diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index 54a92f3c..34f57284 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -262,23 +262,23 @@ namespace WixToolset.Core.WindowsInstaller /// /// Creates an action element. /// - /// The action row from which the element should be created. - private void CreateActionElement(WixActionRow actionRow) + /// The action from which the element should be created. + private void CreateActionElement(WixActionTuple actionTuple) { Wix.ISchemaElement actionElement = null; - if (null != this.core.GetIndexedElement("CustomAction", actionRow.Action)) // custom action + if (null != this.core.GetIndexedElement("CustomAction", actionTuple.Action)) // custom action { var custom = new Wix.Custom(); - custom.Action = actionRow.Action; + custom.Action = actionTuple.Action; - if (null != actionRow.Condition) + if (null != actionTuple.Condition) { - custom.Content = actionRow.Condition; + custom.Content = actionTuple.Condition; } - switch (actionRow.Sequence) + switch (actionTuple.Sequence) { case (-4): custom.OnExit = Wix.ExitType.suspend; @@ -293,35 +293,35 @@ namespace WixToolset.Core.WindowsInstaller custom.OnExit = Wix.ExitType.success; break; default: - if (null != actionRow.Before) + if (null != actionTuple.Before) { - custom.Before = actionRow.Before; + custom.Before = actionTuple.Before; } - else if (null != actionRow.After) + else if (null != actionTuple.After) { - custom.After = actionRow.After; + custom.After = actionTuple.After; } - else if (0 < actionRow.Sequence) + else if (actionTuple.Sequence.HasValue) { - custom.Sequence = actionRow.Sequence; + custom.Sequence = actionTuple.Sequence.Value; } break; } actionElement = custom; } - else if (null != this.core.GetIndexedElement("Dialog", actionRow.Action)) // dialog + else if (null != this.core.GetIndexedElement("Dialog", actionTuple.Action)) // dialog { var show = new Wix.Show(); - show.Dialog = actionRow.Action; + show.Dialog = actionTuple.Action; - if (null != actionRow.Condition) + if (null != actionTuple.Condition) { - show.Content = actionRow.Condition; + show.Content = actionTuple.Condition; } - switch (actionRow.Sequence) + switch (actionTuple.Sequence) { case (-4): show.OnExit = Wix.ExitType.suspend; @@ -336,17 +336,17 @@ namespace WixToolset.Core.WindowsInstaller show.OnExit = Wix.ExitType.success; break; default: - if (null != actionRow.Before) + if (null != actionTuple.Before) { - show.Before = actionRow.Before; + show.Before = actionTuple.Before; } - else if (null != actionRow.After) + else if (null != actionTuple.After) { - show.After = actionRow.After; + show.After = actionTuple.After; } - else if (0 < actionRow.Sequence) + else if (actionTuple.Sequence.HasValue) { - show.Sequence = actionRow.Sequence; + show.Sequence = actionTuple.Sequence.Value; } break; } @@ -355,18 +355,18 @@ namespace WixToolset.Core.WindowsInstaller } else // possibly a standard action without suggested sequence information { - actionElement = this.CreateStandardActionElement(actionRow); + actionElement = this.CreateStandardActionElement(actionTuple); } // add the action element to the appropriate sequence element if (null != actionElement) { - var sequenceTable = actionRow.SequenceTable.ToString(); + var sequenceTable = actionTuple.SequenceTable.ToString(); var sequenceElement = (Wix.IParentElement)this.sequenceElements[sequenceTable]; if (null == sequenceElement) { - switch (actionRow.SequenceTable) + switch (actionTuple.SequenceTable) { case SequenceTable.AdminExecuteSequence: sequenceElement = new Wix.AdminExecuteSequence(); @@ -397,7 +397,7 @@ namespace WixToolset.Core.WindowsInstaller } catch (System.ArgumentException) // action/dialog is not valid for this sequence { - this.Messaging.Write(WarningMessages.IllegalActionInSequence(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(WarningMessages.IllegalActionInSequence(actionTuple.SourceLineNumbers, actionTuple.SequenceTable.ToString(), actionTuple.Action)); } } } @@ -405,40 +405,40 @@ namespace WixToolset.Core.WindowsInstaller /// /// Creates a standard action element. /// - /// The action row from which the element should be created. + /// The action row from which the element should be created. /// The created element. - private Wix.ISchemaElement CreateStandardActionElement(WixActionRow actionRow) + private Wix.ISchemaElement CreateStandardActionElement(WixActionTuple actionTuple) { Wix.ActionSequenceType actionElement = null; - switch (actionRow.Action) + switch (actionTuple.Action) { case "AllocateRegistrySpace": actionElement = new Wix.AllocateRegistrySpace(); break; case "AppSearch": - this.StandardActions.TryGetValue(actionRow.GetPrimaryKey(), out var appSearchActionRow); + this.StandardActions.TryGetValue(actionTuple.Id.Id, out var appSearchActionRow); - if (null != actionRow.Before || null != actionRow.After || (null != appSearchActionRow && actionRow.Sequence != appSearchActionRow.Sequence)) + if (null != actionTuple.Before || null != actionTuple.After || (null != appSearchActionRow && actionTuple.Sequence != appSearchActionRow.Sequence)) { var appSearch = new Wix.AppSearch(); - if (null != actionRow.Condition) + if (null != actionTuple.Condition) { - appSearch.Content = actionRow.Condition; + appSearch.Content = actionTuple.Condition; } - if (null != actionRow.Before) + if (null != actionTuple.Before) { - appSearch.Before = actionRow.Before; + appSearch.Before = actionTuple.Before; } - else if (null != actionRow.After) + else if (null != actionTuple.After) { - appSearch.After = actionRow.After; + appSearch.After = actionTuple.After; } - else if (0 < actionRow.Sequence) + else if (actionTuple.Sequence.HasValue) { - appSearch.Sequence = actionRow.Sequence; + appSearch.Sequence = actionTuple.Sequence.Value; } return appSearch; @@ -449,7 +449,7 @@ namespace WixToolset.Core.WindowsInstaller break; case "CCPSearch": var ccpSearch = new Wix.CCPSearch(); - Decompiler.SequenceRelativeAction(actionRow, ccpSearch); + Decompiler.SequenceRelativeAction(actionTuple, ccpSearch); return ccpSearch; case "CostFinalize": actionElement = new Wix.CostFinalize(); @@ -468,7 +468,7 @@ namespace WixToolset.Core.WindowsInstaller break; case "DisableRollback": var disableRollback = new Wix.DisableRollback(); - Decompiler.SequenceRelativeAction(actionRow, disableRollback); + Decompiler.SequenceRelativeAction(actionTuple, disableRollback); return disableRollback; case "DuplicateFiles": actionElement = new Wix.DuplicateFiles(); @@ -481,22 +481,22 @@ namespace WixToolset.Core.WindowsInstaller break; case "FindRelatedProducts": var findRelatedProducts = new Wix.FindRelatedProducts(); - Decompiler.SequenceRelativeAction(actionRow, findRelatedProducts); + Decompiler.SequenceRelativeAction(actionTuple, findRelatedProducts); return findRelatedProducts; case "ForceReboot": var forceReboot = new Wix.ForceReboot(); - Decompiler.SequenceRelativeAction(actionRow, forceReboot); + Decompiler.SequenceRelativeAction(actionTuple, forceReboot); return forceReboot; case "InstallAdminPackage": actionElement = new Wix.InstallAdminPackage(); break; case "InstallExecute": var installExecute = new Wix.InstallExecute(); - Decompiler.SequenceRelativeAction(actionRow, installExecute); + Decompiler.SequenceRelativeAction(actionTuple, installExecute); return installExecute; case "InstallExecuteAgain": var installExecuteAgain = new Wix.InstallExecuteAgain(); - Decompiler.SequenceRelativeAction(actionRow, installExecuteAgain); + Decompiler.SequenceRelativeAction(actionTuple, installExecuteAgain); return installExecuteAgain; case "InstallFiles": actionElement = new Wix.InstallFiles(); @@ -521,7 +521,7 @@ namespace WixToolset.Core.WindowsInstaller break; case "LaunchConditions": var launchConditions = new Wix.LaunchConditions(); - Decompiler.SequenceRelativeAction(actionRow, launchConditions); + Decompiler.SequenceRelativeAction(actionTuple, launchConditions); return launchConditions; case "MigrateFeatureStates": actionElement = new Wix.MigrateFeatureStates(); @@ -585,7 +585,7 @@ namespace WixToolset.Core.WindowsInstaller break; case "RemoveExistingProducts": var removeExistingProducts = new Wix.RemoveExistingProducts(); - Decompiler.SequenceRelativeAction(actionRow, removeExistingProducts); + Decompiler.SequenceRelativeAction(actionTuple, removeExistingProducts); return removeExistingProducts; case "RemoveFiles": actionElement = new Wix.RemoveFiles(); @@ -607,15 +607,15 @@ namespace WixToolset.Core.WindowsInstaller break; case "ResolveSource": var resolveSource = new Wix.ResolveSource(); - Decompiler.SequenceRelativeAction(actionRow, resolveSource); + Decompiler.SequenceRelativeAction(actionTuple, resolveSource); return resolveSource; case "RMCCPSearch": var rmccpSearch = new Wix.RMCCPSearch(); - Decompiler.SequenceRelativeAction(actionRow, rmccpSearch); + Decompiler.SequenceRelativeAction(actionTuple, rmccpSearch); return rmccpSearch; case "ScheduleReboot": var scheduleReboot = new Wix.ScheduleReboot(); - Decompiler.SequenceRelativeAction(actionRow, scheduleReboot); + Decompiler.SequenceRelativeAction(actionTuple, scheduleReboot); return scheduleReboot; case "SelfRegModules": actionElement = new Wix.SelfRegModules(); @@ -672,13 +672,13 @@ namespace WixToolset.Core.WindowsInstaller actionElement = new Wix.WriteRegistryValues(); break; default: - this.Messaging.Write(WarningMessages.UnknownAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(WarningMessages.UnknownAction(actionTuple.SourceLineNumbers, actionTuple.SequenceTable.ToString(), actionTuple.Action)); return null; } if (actionElement != null) { - this.SequenceStandardAction(actionRow, actionElement); + this.SequenceStandardAction(actionTuple, actionElement); } return actionElement; @@ -687,48 +687,48 @@ namespace WixToolset.Core.WindowsInstaller /// /// Applies the condition and sequence to a standard action element based on the action row data. /// - /// Action row data from the database. + /// Action data from the database. /// Element to be sequenced. - private void SequenceStandardAction(WixActionRow actionRow, Wix.ActionSequenceType actionElement) + private void SequenceStandardAction(WixActionTuple actionTuple, Wix.ActionSequenceType actionElement) { - if (null != actionRow.Condition) + if (null != actionTuple.Condition) { - actionElement.Content = actionRow.Condition; + actionElement.Content = actionTuple.Condition; } - if ((null != actionRow.Before || null != actionRow.After) && 0 == actionRow.Sequence) + if ((null != actionTuple.Before || null != actionTuple.After) && 0 == actionTuple.Sequence) { - this.Messaging.Write(WarningMessages.DecompiledStandardActionRelativelyScheduledInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(WarningMessages.DecompiledStandardActionRelativelyScheduledInModule(actionTuple.SourceLineNumbers, actionTuple.SequenceTable.ToString(), actionTuple.Action)); } - else if (0 < actionRow.Sequence) + else if (actionTuple.Sequence.HasValue) { - actionElement.Sequence = actionRow.Sequence; + actionElement.Sequence = actionTuple.Sequence.Value; } } /// /// Applies the condition and relative sequence to an action element based on the action row data. /// - /// Action row data from the database. + /// Action data from the database. /// Element to be sequenced. - private static void SequenceRelativeAction(WixActionRow actionRow, Wix.ActionModuleSequenceType actionElement) + private static void SequenceRelativeAction(WixActionTuple actionTuple, Wix.ActionModuleSequenceType actionElement) { - if (null != actionRow.Condition) + if (null != actionTuple.Condition) { - actionElement.Content = actionRow.Condition; + actionElement.Content = actionTuple.Condition; } - if (null != actionRow.Before) + if (null != actionTuple.Before) { - actionElement.Before = actionRow.Before; + actionElement.Before = actionTuple.Before; } - else if (null != actionRow.After) + else if (null != actionTuple.After) { - actionElement.After = actionRow.After; + actionElement.After = actionTuple.After; } - else if (0 < actionRow.Sequence) + else if (actionTuple.Sequence.HasValue) { - actionElement.Sequence = actionRow.Sequence; + actionElement.Sequence = actionTuple.Sequence.Value; } } @@ -2495,7 +2495,7 @@ namespace WixToolset.Core.WindowsInstaller { foreach (SequenceTable sequenceTable in Enum.GetValues(typeof(SequenceTable))) { - var sequenceTableName = GetSequenceTableName(sequenceTable); + var sequenceTableName = sequenceTable.WindowsInstallerTableName(); // if suppressing UI elements, skip UI-related sequence tables if (this.SuppressUI && ("AdminUISequence" == sequenceTableName || "InstallUISequence" == sequenceTableName)) @@ -2503,57 +2503,57 @@ namespace WixToolset.Core.WindowsInstaller continue; } - var actionsTable = new Table(this.tableDefinitions["WixAction"]); var table = tables[sequenceTableName]; if (null != table) { - var actionRows = new List(); + var actionTuples = new List(); var needAbsoluteScheduling = this.SuppressRelativeActionSequencing; - var nonSequencedActionRows = new Dictionary(); - var suppressedRelativeActionRows = new Dictionary(); + var nonSequencedActionRows = new Dictionary(); + var suppressedRelativeActionRows = new Dictionary(); // create a sorted array of actions in this table foreach (var row in table.Rows) { - var actionRow = (WixActionRow)actionsTable.CreateRow(null); + var action = row.FieldAsString(0); + var actionTuple = new WixActionTuple(null, new Identifier(AccessModifier.Public, sequenceTable, action)); - actionRow.Action = Convert.ToString(row[0]); + actionTuple.Action = action; if (null != row[1]) { - actionRow.Condition = Convert.ToString(row[1]); + actionTuple.Condition = Convert.ToString(row[1]); } - actionRow.Sequence = Convert.ToInt32(row[2]); + actionTuple.Sequence = Convert.ToInt32(row[2]); - actionRow.SequenceTable = sequenceTable; + actionTuple.SequenceTable = sequenceTable; - actionRows.Add(actionRow); + actionTuples.Add(actionTuple); } - actionRows.Sort(); + actionTuples = actionTuples.OrderBy(t => t.Sequence).ToList(); - for (var i = 0; i < actionRows.Count && !needAbsoluteScheduling; i++) + for (var i = 0; i < actionTuples.Count && !needAbsoluteScheduling; i++) { - var actionRow = actionRows[i]; - this.StandardActions.TryGetValue(actionRow.GetPrimaryKey(), out var standardActionRow); + var actionTuple = actionTuples[i]; + this.StandardActions.TryGetValue(actionTuple.Id.Id, out var standardActionRow); // create actions for custom actions, dialogs, AppSearch when its moved, and standard actions with non-standard conditions - if ("AppSearch" == actionRow.Action || null == standardActionRow || actionRow.Condition != standardActionRow.Condition) + if ("AppSearch" == actionTuple.Action || null == standardActionRow || actionTuple.Condition != standardActionRow.Condition) { - WixActionRow previousActionRow = null; - WixActionRow nextActionRow = null; + WixActionTuple previousActionTuple = null; + WixActionTuple nextActionTuple = null; // find the previous action row if there is one if (0 <= i - 1) { - previousActionRow = actionRows[i - 1]; + previousActionTuple = actionTuples[i - 1]; } // find the next action row if there is one - if (actionRows.Count > i + 1) + if (actionTuples.Count > i + 1) { - nextActionRow = actionRows[i + 1]; + nextActionTuple = actionTuples[i + 1]; } // the logic for setting the before or after attribute for an action: @@ -2565,49 +2565,49 @@ namespace WixToolset.Core.WindowsInstaller // 6. If this action is AppSearch and has all standard information, ignore it. // 7. If this action is standard and has a non-standard condition, create the action without any scheduling information. // 8. Everything must be absolutely sequenced. - if ((null != previousActionRow && actionRow.Sequence == previousActionRow.Sequence) || (null != nextActionRow && actionRow.Sequence == nextActionRow.Sequence)) + if ((null != previousActionTuple && actionTuple.Sequence == previousActionTuple.Sequence) || (null != nextActionTuple && actionTuple.Sequence == nextActionTuple.Sequence)) { needAbsoluteScheduling = true; } - else if (null != nextActionRow && this.StandardActions.ContainsKey(nextActionRow.GetPrimaryKey()) && actionRow.Sequence + 1 == nextActionRow.Sequence) + else if (null != nextActionTuple && this.StandardActions.ContainsKey(nextActionTuple.Id.Id) && actionTuple.Sequence + 1 == nextActionTuple.Sequence) { - actionRow.Before = nextActionRow.Action; + actionTuple.Before = nextActionTuple.Action; } - else if (null != previousActionRow && this.StandardActions.ContainsKey(previousActionRow.GetPrimaryKey()) && actionRow.Sequence - 1 == previousActionRow.Sequence) + else if (null != previousActionTuple && this.StandardActions.ContainsKey(previousActionTuple.Id.Id) && actionTuple.Sequence - 1 == previousActionTuple.Sequence) { - actionRow.After = previousActionRow.Action; + actionTuple.After = previousActionTuple.Action; } - else if (null == standardActionRow && null != previousActionRow && actionRow.Sequence - 1 == previousActionRow.Sequence && previousActionRow.Before != actionRow.Action) + else if (null == standardActionRow && null != previousActionTuple && actionTuple.Sequence - 1 == previousActionTuple.Sequence && previousActionTuple.Before != actionTuple.Action) { - actionRow.After = previousActionRow.Action; + actionTuple.After = previousActionTuple.Action; } - else if (null == standardActionRow && null != previousActionRow && actionRow.Sequence != previousActionRow.Sequence && null != nextActionRow && actionRow.Sequence + 1 == nextActionRow.Sequence) + else if (null == standardActionRow && null != previousActionTuple && actionTuple.Sequence != previousActionTuple.Sequence && null != nextActionTuple && actionTuple.Sequence + 1 == nextActionTuple.Sequence) { - actionRow.Before = nextActionRow.Action; + actionTuple.Before = nextActionTuple.Action; } - else if ("AppSearch" == actionRow.Action && null != standardActionRow && actionRow.Sequence == standardActionRow.Sequence && actionRow.Condition == standardActionRow.Condition) + else if ("AppSearch" == actionTuple.Action && null != standardActionRow && actionTuple.Sequence == standardActionRow.Sequence && actionTuple.Condition == standardActionRow.Condition) { // ignore an AppSearch row which has the WiX standard sequence and a standard condition } - else if (null != standardActionRow && actionRow.Condition != standardActionRow.Condition) // standard actions get their standard sequence numbers + else if (null != standardActionRow && actionTuple.Condition != standardActionRow.Condition) // standard actions get their standard sequence numbers { - nonSequencedActionRows.Add(actionRow.GetPrimaryKey(), actionRow); + nonSequencedActionRows.Add(actionTuple.Id.Id, actionTuple); } - else if (0 < actionRow.Sequence) + else if (0 < actionTuple.Sequence) { needAbsoluteScheduling = true; } } else { - suppressedRelativeActionRows.Add(actionRow.GetPrimaryKey(), actionRow); + suppressedRelativeActionRows.Add(actionTuple.Id.Id, actionTuple); } } // create the actions now that we know if they must be absolutely or relatively scheduled - foreach (var actionRow in actionRows) + foreach (var actionRow in actionTuples) { - var key = actionRow.GetPrimaryKey(); + var key = actionRow.Id.Id; if (needAbsoluteScheduling) { @@ -2636,7 +2636,7 @@ namespace WixToolset.Core.WindowsInstaller { foreach (SequenceTable sequenceTable in Enum.GetValues(typeof(SequenceTable))) { - var sequenceTableName = GetSequenceTableName(sequenceTable); + var sequenceTableName = sequenceTable.WindowsInstallerTableName(); // if suppressing UI elements, skip UI-related sequence tables if (this.SuppressUI && ("AdminUISequence" == sequenceTableName || "InstallUISequence" == sequenceTableName)) @@ -2651,9 +2651,9 @@ namespace WixToolset.Core.WindowsInstaller { foreach (var row in table.Rows) { - var actionRow = (WixActionRow)actionsTable.CreateRow(null); + var actionRow = new WixActionTuple(null, new Identifier(AccessModifier.Public, sequenceTable, row.FieldAsString(0))); - actionRow.Action = Convert.ToString(row[0]); + actionRow.Action = row.FieldAsString(0); if (null != row[1]) { @@ -2684,7 +2684,7 @@ namespace WixToolset.Core.WindowsInstaller actionRow.SequenceTable = sequenceTable; // create action elements for non-standard actions - if (!this.StandardActions.ContainsKey(actionRow.GetPrimaryKey()) || null != actionRow.After || null != actionRow.Before) + if (!this.StandardActions.ContainsKey(actionRow.Id.Id) || null != actionRow.After || null != actionRow.Before) { this.CreateActionElement(actionRow); } @@ -2844,17 +2844,6 @@ namespace WixToolset.Core.WindowsInstaller } } - private static string GetSequenceTableName(SequenceTable sequenceTable) - { - switch (sequenceTable) - { - case SequenceTable.AdvertiseExecuteSequence: - return "AdvtExecuteSequence"; - default: - return sequenceTable.ToString(); - } - } - /// /// Get the path to a file in the source image. /// -- cgit v1.2.3-55-g6feb