From d56481c18f831991cc36d9720e06ce6874f1bea1 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 31 Dec 2023 17:08:45 -0500 Subject: [PATCH] Rename IWindowsInstallerDecompileContext... ...TreatProductAsModule to KeepModularizationIds to better describe what it does. Fixes https://github.com/wixtoolset/issues/issues/7607. --- .../Data/IWindowsInstallerDecompileContext.cs | 2 +- .../Decompile/Decompiler.cs | 8 ++++---- src/wix/WixToolset.Core.WindowsInstaller/Melter.cs | 2 +- .../WindowsInstallerDecompileContext.cs | 2 +- .../WindowsInstallerDecompiler.cs | 12 ++---------- .../DecompileFixture.cs | 4 ++-- 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs index 845c89a5f..1d729b721 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs @@ -96,6 +96,6 @@ public interface IWindowsInstallerDecompileContext /// Gets or sets whether the decompiler should keep modularization /// GUIDs (true) or remove them (default/false). /// - bool TreatProductAsModule { get; set; } + bool KeepModularizationIds { get; set; } } } diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index 71e1b22be..e3609b307 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -43,7 +43,7 @@ internal class Decompiler /// /// Creates a new decompiler object with a default set of table definitions. /// - public Decompiler(IMessaging messaging, IBackendHelper backendHelper, IWindowsInstallerDecompilerHelper decompilerHelper, IEnumerable extensions, IEnumerable extensionData, ISymbolDefinitionCreator creator, string baseSourcePath, bool suppressCustomTables, bool suppressDroppingEmptyTables, bool suppressRelativeActionSequencing, bool suppressUI, bool treatProductAsModule) + public Decompiler(IMessaging messaging, IBackendHelper backendHelper, IWindowsInstallerDecompilerHelper decompilerHelper, IEnumerable extensions, IEnumerable extensionData, ISymbolDefinitionCreator creator, string baseSourcePath, bool suppressCustomTables, bool suppressDroppingEmptyTables, bool suppressRelativeActionSequencing, bool suppressUI, bool keepModularizationIds) { this.Messaging = messaging; this.BackendHelper = backendHelper; @@ -56,7 +56,7 @@ public Decompiler(IMessaging messaging, IBackendHelper backendHelper, IWindowsIn this.SuppressDroppingEmptyTables = suppressDroppingEmptyTables; this.SuppressRelativeActionSequencing = suppressRelativeActionSequencing; this.SuppressUI = suppressUI; - this.TreatProductAsModule = treatProductAsModule; + this.KeepModularizationIds = keepModularizationIds; this.ExtensionsByTableName = new Dictionary(); this.StandardActions = WindowsInstallerStandard.StandardActions().ToDictionary(a => a.Id.Id); @@ -88,7 +88,7 @@ public Decompiler(IMessaging messaging, IBackendHelper backendHelper, IWindowsIn private bool SuppressUI { get; } - private bool TreatProductAsModule { get; } + private bool KeepModularizationIds { get; } private OutputType OutputType { get; set; } @@ -1188,7 +1188,7 @@ private void FinalizeFileTable(TableIndexedCollection tables) var fileName = xFile?.Attribute("Name")?.Value; // set the source (done here because it requires information from the Directory table) - if (OutputType.Module == this.OutputType && !this.TreatProductAsModule) + if (OutputType.Module == this.OutputType && !this.KeepModularizationIds) { xFile.SetAttributeValue("Source", String.Concat(this.BaseSourcePath, Path.DirectorySeparatorChar, "File", Path.DirectorySeparatorChar, fileId, '.', this.ModularizationGuid.Substring(1, 36).Replace('-', '_'))); } diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Melter.cs b/src/wix/WixToolset.Core.WindowsInstaller/Melter.cs index 7073e9529..10a60eb86 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Melter.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Melter.cs @@ -85,7 +85,7 @@ public Wix.Wix Melt(Output wixout) PreDecompile(wixout); wixout.Type = OutputType.Package; - this.decompiler.TreatProductAsModule = true; + this.decompiler.KeepModularizationIds = true; Wix.Wix wix = this.decompiler.Decompile(wixout); if (null == wix) diff --git a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompileContext.cs b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompileContext.cs index 22745ab0f..13065fb5c 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompileContext.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompileContext.cs @@ -49,6 +49,6 @@ internal WindowsInstallerDecompileContext(IServiceProvider serviceProvider) public bool SuppressUI { get; set; } - public bool TreatProductAsModule { get; set; } + public bool KeepModularizationIds { get; set; } } } diff --git a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs index 267fe4954..56ebd5f38 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs @@ -94,21 +94,13 @@ private IWindowsInstallerDecompileResult DecompileDatabase(IWindowsInstallerDeco var extractFilesFolder = context.SuppressExtractCabinets || (String.IsNullOrEmpty(context.CabinetExtractFolder) && String.IsNullOrEmpty(context.ExtractFolder)) ? null : String.IsNullOrEmpty(context.CabinetExtractFolder) ? Path.Combine(context.ExtractFolder, "File") : context.CabinetExtractFolder; - // IWindowsInstallerDecompileContext.TreatProductAsModule is broken. So broken, in fact, - // that it's been broken since WiX v3.0 in 2008. It was introduced (according to lore) - // to support Melt, which decompiles merge modules into fragments so you can consume - // merge modules without actually going through the black box that is mergemod.dll. But - // the name is wrong: It's not TreatProductAsModule; if anything it should instead be - // TreatModuleAsProduct, though even that's wrong (because you want a fragment, not a - // product/package). In WiX v5, rename to `KeepModularizeIds` (or something better) to - // reflect the functionality. - var demodularize = !context.TreatProductAsModule; + var demodularize = !context.KeepModularizationIds; var sectionType = context.DecompileType; var unbindCommand = new UnbindDatabaseCommand(this.Messaging, backendHelper, fileSystem, pathResolver, context.DecompilePath, null, sectionType, context.ExtractFolder, extractFilesFolder, context.IntermediateFolder, demodularize, skipSummaryInfo: false); var output = unbindCommand.Execute(); var extractedFilePaths = unbindCommand.ExportedFiles; - var decompiler = new Decompiler(this.Messaging, backendHelper, decompilerHelper, context.Extensions, context.ExtensionData, context.SymbolDefinitionCreator, context.BaseSourcePath, context.SuppressCustomTables, context.SuppressDroppingEmptyTables, context.SuppressRelativeActionSequencing, context.SuppressUI, context.TreatProductAsModule); + var decompiler = new Decompiler(this.Messaging, backendHelper, decompilerHelper, context.Extensions, context.ExtensionData, context.SymbolDefinitionCreator, context.BaseSourcePath, context.SuppressCustomTables, context.SuppressDroppingEmptyTables, context.SuppressRelativeActionSequencing, context.SuppressUI, context.KeepModularizationIds); var document = decompiler.Decompile(output); var result = context.ServiceProvider.GetService(); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs index 01882feff..86da7ebdf 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs @@ -108,7 +108,7 @@ public void CanDecompileUI() } [Fact] - public void CanDecompileMergeModuleWithTreatProductAsModule() + public void CanDecompileMergeModuleWithKeepModularizationIds() { using (var fs = new DisposableFileSystem()) { @@ -127,7 +127,7 @@ public void CanDecompileMergeModuleWithTreatProductAsModule() context.ExtensionData = extensionManager.GetServices(); context.DecompilePath = Path.Combine(sourceFolder, "MergeModule1.msm"); context.DecompileType = OutputType.Module; - context.TreatProductAsModule = true; + context.KeepModularizationIds = true; context.IntermediateFolder = intermediateFolder; context.ExtractFolder = outputFolder; context.CabinetExtractFolder = outputFolder;