Skip to content

Commit

Permalink
Rename IWindowsInstallerDecompileContext...
Browse files Browse the repository at this point in the history
...TreatProductAsModule to KeepModularizationIds to better describe what
it does.

Fixes wixtoolset/issues#7607.
  • Loading branch information
barnson committed Dec 31, 2023
1 parent c890f0e commit d56481c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ public interface IWindowsInstallerDecompileContext
/// Gets or sets whether the decompiler should keep modularization
/// GUIDs (true) or remove them (default/false).
/// </summary>
bool TreatProductAsModule { get; set; }
bool KeepModularizationIds { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal class Decompiler
/// <summary>
/// Creates a new decompiler object with a default set of table definitions.
/// </summary>
public Decompiler(IMessaging messaging, IBackendHelper backendHelper, IWindowsInstallerDecompilerHelper decompilerHelper, IEnumerable<IWindowsInstallerDecompilerExtension> extensions, IEnumerable<IExtensionData> extensionData, ISymbolDefinitionCreator creator, string baseSourcePath, bool suppressCustomTables, bool suppressDroppingEmptyTables, bool suppressRelativeActionSequencing, bool suppressUI, bool treatProductAsModule)
public Decompiler(IMessaging messaging, IBackendHelper backendHelper, IWindowsInstallerDecompilerHelper decompilerHelper, IEnumerable<IWindowsInstallerDecompilerExtension> extensions, IEnumerable<IExtensionData> extensionData, ISymbolDefinitionCreator creator, string baseSourcePath, bool suppressCustomTables, bool suppressDroppingEmptyTables, bool suppressRelativeActionSequencing, bool suppressUI, bool keepModularizationIds)
{
this.Messaging = messaging;
this.BackendHelper = backendHelper;
Expand All @@ -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<string, IWindowsInstallerDecompilerExtension>();
this.StandardActions = WindowsInstallerStandard.StandardActions().ToDictionary(a => a.Id.Id);
Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -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('-', '_')));
}
Expand Down
2 changes: 1 addition & 1 deletion src/wix/WixToolset.Core.WindowsInstaller/Melter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ internal WindowsInstallerDecompileContext(IServiceProvider serviceProvider)

public bool SuppressUI { get; set; }

public bool TreatProductAsModule { get; set; }
public bool KeepModularizationIds { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<IWindowsInstallerDecompileResult>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void CanDecompileUI()
}

[Fact]
public void CanDecompileMergeModuleWithTreatProductAsModule()
public void CanDecompileMergeModuleWithKeepModularizationIds()
{
using (var fs = new DisposableFileSystem())
{
Expand All @@ -127,7 +127,7 @@ public void CanDecompileMergeModuleWithTreatProductAsModule()
context.ExtensionData = extensionManager.GetServices<IExtensionData>();
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;
Expand Down

0 comments on commit d56481c

Please sign in to comment.