From 41e60175f6db63cb988a9340c950c224dc472814 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 24 Oct 2018 20:56:32 -0700 Subject: Re-introduce "decompile" to backend --- .../Data/DecompileResult.cs | 13 +++++ .../Data/IDecompileContext.cs | 55 ++++++++++++++++++++++ .../DecompilerConstants.cs | 4 +- src/WixToolset.Extensibility/IBackend.cs | 4 +- .../IDecompilerExtension.cs | 37 +++------------ .../IWindowsInstallerBackendDecompilerExtension.cs | 43 +++++++++++++++++ 6 files changed, 121 insertions(+), 35 deletions(-) create mode 100644 src/WixToolset.Extensibility/Data/DecompileResult.cs create mode 100644 src/WixToolset.Extensibility/Data/IDecompileContext.cs create mode 100644 src/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs diff --git a/src/WixToolset.Extensibility/Data/DecompileResult.cs b/src/WixToolset.Extensibility/Data/DecompileResult.cs new file mode 100644 index 00000000..29da4887 --- /dev/null +++ b/src/WixToolset.Extensibility/Data/DecompileResult.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Data +{ + using System.Collections.Generic; + + public class DecompileResult + { + public string SourceDocumentPath { get; set; } + + public IEnumerable ExtractedFilePaths { get; set; } + } +} diff --git a/src/WixToolset.Extensibility/Data/IDecompileContext.cs b/src/WixToolset.Extensibility/Data/IDecompileContext.cs new file mode 100644 index 00000000..fb846878 --- /dev/null +++ b/src/WixToolset.Extensibility/Data/IDecompileContext.cs @@ -0,0 +1,55 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Data +{ + using System; + using System.Collections.Generic; + using WixToolset.Data; + + public interface IDecompileContext + { + IServiceProvider ServiceProvider { get; } + + string DecompilePath { get; set; } + + OutputType DecompileType { get; set; } + + IEnumerable Extensions { get; set; } + + string ExtractFolder { get; set; } + + /// + /// Optional gets or sets the base path for the File/@Source. + /// + /// Default value is "SourceDir" to enable use of BindPaths. + string BaseSourcePath { get; set; } + + string IntermediateFolder { get; set; } + + bool IsAdminImage { get; set; } + + string OutputPath { get; set; } + + /// + /// Gets or sets the option to suppress custom tables. + /// + bool SuppressCustomTables { get; set; } + + /// + /// Gets or sets the option to suppress dropping empty tables. + /// + bool SuppressDroppingEmptyTables { get; set; } + + bool SuppressExtractCabinets { get; set; } + + /// + /// Gets or sets the option to suppress decompiling UI-related tables. + /// + bool SuppressUI { get; set; } + + /// + /// Gets or sets whether the decompiler should use module logic on a product output. + /// + bool TreatProductAsModule { get; set; } + } +} diff --git a/src/WixToolset.Extensibility/DecompilerConstants.cs b/src/WixToolset.Extensibility/DecompilerConstants.cs index 58742182..8cd6b19c 100644 --- a/src/WixToolset.Extensibility/DecompilerConstants.cs +++ b/src/WixToolset.Extensibility/DecompilerConstants.cs @@ -1,9 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset +namespace WixToolset.Extensibility { - using System; - /// /// Constants used by decompiler. /// diff --git a/src/WixToolset.Extensibility/IBackend.cs b/src/WixToolset.Extensibility/IBackend.cs index 80f885c3..df693561 100644 --- a/src/WixToolset.Extensibility/IBackend.cs +++ b/src/WixToolset.Extensibility/IBackend.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Extensibility { @@ -9,6 +9,8 @@ namespace WixToolset.Extensibility { BindResult Bind(IBindContext context); + DecompileResult Decompile(IDecompileContext context); + Intermediate Unbind(IUnbindContext context); bool Inscribe(IInscribeContext context); diff --git a/src/WixToolset.Extensibility/IDecompilerExtension.cs b/src/WixToolset.Extensibility/IDecompilerExtension.cs index e2b80089..9ea4290b 100644 --- a/src/WixToolset.Extensibility/IDecompilerExtension.cs +++ b/src/WixToolset.Extensibility/IDecompilerExtension.cs @@ -2,46 +2,21 @@ namespace WixToolset.Extensibility { + using WixToolset.Extensibility.Data; + /// /// Base class for creating a decompiler extension. /// public interface IDecompilerExtension { /// - /// Gets or sets the decompiler core for the extension. - /// - /// The decompiler core for the extension. - IDecompilerCore Core { get; set; } - - /// - /// Gets the table definitions this extension decompiles. - /// - /// Table definitions this extension decompiles. - //TableDefinitionCollection TableDefinitions { get; } - - /// - /// Gets the library that this decompiler wants removed from the decomipiled output. - /// - /// The table definitions to use while loading the library. - /// The library for this extension or null if there is no library to be removed. - //Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions); - - /// - /// Called at the beginning of the decompilation of a database. - /// - /// The collection of all tables. - //void Initialize(TableIndexedCollection tables); - - /// - /// Decompiles an extension table. + /// Called before decompiling occurs. /// - /// The table to decompile. - //void DecompileTable(Table table); + void PreDecompile(IDecompileContext context); /// - /// Finalize decompilation. + /// Called after all decompiling occurs. /// - /// The collection of all tables. - //void Finish(TableIndexedCollection tables); + void PostDecompile(DecompileResult result); } } diff --git a/src/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs b/src/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs new file mode 100644 index 00000000..05899c1f --- /dev/null +++ b/src/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs @@ -0,0 +1,43 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility +{ + using WixToolset.Data; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Data; + + /// + /// Interface all binder extensions implement. + /// + public interface IWindowsInstallerBackendDecompilerExtension + { + /// + /// Called before decompiling occurs. + /// + void PreBackendDecompile(IDecompileContext context); + + /// + /// Gets the table definitions this extension decompiles. + /// + /// Table definitions this extension decompiles. + TableDefinitionCollection TableDefinitions { get; } + + /// + /// Gets the library that this decompiler wants removed from the decomipiled output. + /// + /// The table definitions to use while loading the library. + /// The library for this extension or null if there is no library to be removed. + Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions); + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + void DecompileTable(Table table); + + /// + /// Called after all output changes occur and right before the output is bound into its final format. + /// + void PostBackendDecompile(DecompileResult result); + } +} -- cgit v1.2.3-55-g6feb