diff options
| author | Rob Mensching <rob@firegiant.com> | 2022-03-23 10:25:49 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2022-03-30 14:12:12 -0700 |
| commit | c86a2148f6dd7bfcd6637b6e1c9e7b5a9b53a996 (patch) | |
| tree | 547736274aca4871f71578222e74d9972609c0c6 /src/api | |
| parent | eedde7ee47ab7b3bef417f2d631814b586cdb011 (diff) | |
| download | wix-c86a2148f6dd7bfcd6637b6e1c9e7b5a9b53a996.tar.gz wix-c86a2148f6dd7bfcd6637b6e1c9e7b5a9b53a996.tar.bz2 wix-c86a2148f6dd7bfcd6637b6e1c9e7b5a9b53a996.zip | |
Make "decompile" an MSI-only command instead of a backend requirement
As much as I'd like decompiling to be global functionality provided
by all backends there are only two output types that support
decompiling: MSI and MSM. In the future, perhaps we can invest in a
generic symbols to source code converter that would reduce the
redundant work backends need to do today. Until then, make
decompile an MSI specific command
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs (renamed from src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs) | 44 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileResult.cs (renamed from src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs) | 2 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/IBackend.cs | 3 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/IBackendFactory.cs | 6 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs | 22 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs (renamed from src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs) | 6 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs | 97 |
7 files changed, 133 insertions, 47 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs index fe7d0465..f744121a 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs | |||
| @@ -5,21 +5,40 @@ namespace WixToolset.Extensibility.Data | |||
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using WixToolset.Data; | 7 | using WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | 8 | ||
| 10 | #pragma warning disable 1591 // TODO: add documentation | 9 | /// <summary> |
| 11 | public interface IDecompileContext | 10 | /// The context used to decompile Windows Installer packages. |
| 11 | /// </summary> | ||
| 12 | public interface IWindowsInstallerDecompileContext | ||
| 12 | { | 13 | { |
| 14 | /// <summary> | ||
| 15 | /// Gets or sets the service provider. | ||
| 16 | /// </summary> | ||
| 13 | IServiceProvider ServiceProvider { get; } | 17 | IServiceProvider ServiceProvider { get; } |
| 14 | 18 | ||
| 19 | /// <summary> | ||
| 20 | /// Gets or sets the path to the file to decompile. | ||
| 21 | /// </summary> | ||
| 15 | string DecompilePath { get; set; } | 22 | string DecompilePath { get; set; } |
| 16 | 23 | ||
| 24 | /// <summary> | ||
| 25 | /// Gets or sets the type to decompile. | ||
| 26 | /// </summary> | ||
| 17 | OutputType DecompileType { get; set; } | 27 | OutputType DecompileType { get; set; } |
| 18 | 28 | ||
| 19 | IReadOnlyCollection<IDecompilerExtension> Extensions { get; set; } | 29 | /// <summary> |
| 30 | /// Gets or sets the decompiler extensions. | ||
| 31 | /// </summary> | ||
| 32 | IReadOnlyCollection<IWindowsInstallerDecompilerExtension> Extensions { get; set; } | ||
| 20 | 33 | ||
| 34 | /// <summary> | ||
| 35 | /// Gets or sets the folder where content is extracted. | ||
| 36 | /// </summary> | ||
| 21 | string ExtractFolder { get; set; } | 37 | string ExtractFolder { get; set; } |
| 22 | 38 | ||
| 39 | /// <summary> | ||
| 40 | /// Gets or sets the folder where files are extracted. | ||
| 41 | /// </summary> | ||
| 23 | string CabinetExtractFolder { get; set; } | 42 | string CabinetExtractFolder { get; set; } |
| 24 | 43 | ||
| 25 | /// <summary> | 44 | /// <summary> |
| @@ -28,10 +47,19 @@ namespace WixToolset.Extensibility.Data | |||
| 28 | /// <remarks>Default value is "SourceDir" to enable use of BindPaths.</remarks> | 47 | /// <remarks>Default value is "SourceDir" to enable use of BindPaths.</remarks> |
| 29 | string BaseSourcePath { get; set; } | 48 | string BaseSourcePath { get; set; } |
| 30 | 49 | ||
| 50 | /// <summary> | ||
| 51 | /// Gets or sets the intermediate folder. | ||
| 52 | /// </summary> | ||
| 31 | string IntermediateFolder { get; set; } | 53 | string IntermediateFolder { get; set; } |
| 32 | 54 | ||
| 55 | /// <summary> | ||
| 56 | /// Gets or sets whether the decompiler admin image. | ||
| 57 | /// </summary> | ||
| 33 | bool IsAdminImage { get; set; } | 58 | bool IsAdminImage { get; set; } |
| 34 | 59 | ||
| 60 | /// <summary> | ||
| 61 | /// Gets or sets where to output the result. | ||
| 62 | /// </summary> | ||
| 35 | string OutputPath { get; set; } | 63 | string OutputPath { get; set; } |
| 36 | 64 | ||
| 37 | /// <summary> | 65 | /// <summary> |
| @@ -44,9 +72,17 @@ namespace WixToolset.Extensibility.Data | |||
| 44 | /// </summary> | 72 | /// </summary> |
| 45 | bool SuppressDroppingEmptyTables { get; set; } | 73 | bool SuppressDroppingEmptyTables { get; set; } |
| 46 | 74 | ||
| 75 | /// <summary> | ||
| 76 | /// Gets or sets whether to prevent extract cabinets. | ||
| 77 | /// </summary> | ||
| 47 | bool SuppressExtractCabinets { get; set; } | 78 | bool SuppressExtractCabinets { get; set; } |
| 48 | 79 | ||
| 49 | /// <summary> | 80 | /// <summary> |
| 81 | /// Gets or sets whether to suppress relative action sequencing. | ||
| 82 | /// </summary> | ||
| 83 | bool SuppressRelativeActionSequencing { get; set; } | ||
| 84 | |||
| 85 | /// <summary> | ||
| 50 | /// Gets or sets the option to suppress decompiling UI-related tables. | 86 | /// Gets or sets the option to suppress decompiling UI-related tables. |
| 51 | /// </summary> | 87 | /// </summary> |
| 52 | bool SuppressUI { get; set; } | 88 | bool SuppressUI { get; set; } |
diff --git a/src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileResult.cs index cffd0976..3b1dd815 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileResult.cs | |||
| @@ -7,7 +7,7 @@ namespace WixToolset.Extensibility.Data | |||
| 7 | using WixToolset.Data; | 7 | using WixToolset.Data; |
| 8 | 8 | ||
| 9 | #pragma warning disable 1591 // TODO: add documentation | 9 | #pragma warning disable 1591 // TODO: add documentation |
| 10 | public interface IDecompileResult | 10 | public interface IWindowsInstallerDecompileResult |
| 11 | { | 11 | { |
| 12 | XDocument Document { get; set; } | 12 | XDocument Document { get; set; } |
| 13 | 13 | ||
diff --git a/src/api/wix/WixToolset.Extensibility/IBackend.cs b/src/api/wix/WixToolset.Extensibility/IBackend.cs index cb151e05..720abe15 100644 --- a/src/api/wix/WixToolset.Extensibility/IBackend.cs +++ b/src/api/wix/WixToolset.Extensibility/IBackend.cs | |||
| @@ -15,8 +15,5 @@ namespace WixToolset.Extensibility | |||
| 15 | /// <param name="context">Bind context.</param> | 15 | /// <param name="context">Bind context.</param> |
| 16 | /// <returns>Result of the bind operation.</returns> | 16 | /// <returns>Result of the bind operation.</returns> |
| 17 | IBindResult Bind(IBindContext context); | 17 | IBindResult Bind(IBindContext context); |
| 18 | |||
| 19 | #pragma warning disable 1591 // TODO: add documentation | ||
| 20 | IDecompileResult Decompile(IDecompileContext context); | ||
| 21 | } | 18 | } |
| 22 | } | 19 | } |
diff --git a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs index 7f9ef62d..8e84f5b6 100644 --- a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs +++ b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
| 4 | { | 4 | { |
| 5 | /// <summary> | 5 | /// <summary> |
| 6 | /// Implemented by extensions to create backends. | 6 | /// Implemented by extensions that are backends. |
| 7 | /// </summary> | 7 | /// </summary> |
| 8 | public interface IBackendFactory | 8 | public interface IBackendFactory |
| 9 | { | 9 | { |
| @@ -12,8 +12,8 @@ namespace WixToolset.Extensibility | |||
| 12 | /// </summary> | 12 | /// </summary> |
| 13 | /// <param name="outputType">Type of output being created.</param> | 13 | /// <param name="outputType">Type of output being created.</param> |
| 14 | /// <param name="outputPath">Path to the output to create.</param> | 14 | /// <param name="outputPath">Path to the output to create.</param> |
| 15 | /// <param name="backend">The backend for the output.</param> | 15 | /// <param name="binder">The backend for the output.</param> |
| 16 | /// <returns>True if the backend was created, otherwise false.</returns> | 16 | /// <returns>True if the backend was created, otherwise false.</returns> |
| 17 | bool TryCreateBackend(string outputType, string outputPath, out IBackend backend); | 17 | bool TryCreateBackend(string outputType, string outputPath, out IBackend binder); |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
diff --git a/src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs deleted file mode 100644 index 24ef3bff..00000000 --- a/src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Extensibility | ||
| 4 | { | ||
| 5 | using WixToolset.Extensibility.Data; | ||
| 6 | |||
| 7 | /// <summary> | ||
| 8 | /// Base class for creating a decompiler extension. | ||
| 9 | /// </summary> | ||
| 10 | public interface IDecompilerExtension | ||
| 11 | { | ||
| 12 | /// <summary> | ||
| 13 | /// Called before decompiling occurs. | ||
| 14 | /// </summary> | ||
| 15 | void PreDecompile(IDecompileContext context); | ||
| 16 | |||
| 17 | /// <summary> | ||
| 18 | /// Called after all decompiling occurs. | ||
| 19 | /// </summary> | ||
| 20 | void PostDecompile(IDecompileResult result); | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs index a56b63c3..add5f886 100644 --- a/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs +++ b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs | |||
| @@ -9,18 +9,18 @@ namespace WixToolset.Extensibility | |||
| 9 | /// <summary> | 9 | /// <summary> |
| 10 | /// Interface all binder extensions implement. | 10 | /// Interface all binder extensions implement. |
| 11 | /// </summary> | 11 | /// </summary> |
| 12 | public interface IWindowsInstallerBackendDecompilerExtension | 12 | public interface IWindowsInstallerDecompilerExtension |
| 13 | { | 13 | { |
| 14 | /// <summary> | 14 | /// <summary> |
| 15 | /// Called before decompiling occurs. | 15 | /// Called before decompiling occurs. |
| 16 | /// </summary> | 16 | /// </summary> |
| 17 | void PreBackendDecompile(IDecompileContext context); | 17 | void PreDecompile(IWindowsInstallerDecompileContext context); |
| 18 | 18 | ||
| 19 | // TODO: Redesign this interface to be useful. | 19 | // TODO: Redesign this interface to be useful. |
| 20 | 20 | ||
| 21 | /// <summary> | 21 | /// <summary> |
| 22 | /// Called after all output changes occur and right before the output is bound into its final format. | 22 | /// Called after all output changes occur and right before the output is bound into its final format. |
| 23 | /// </summary> | 23 | /// </summary> |
| 24 | void PostBackendDecompile(IDecompileResult result); | 24 | void PostDecompile(IWindowsInstallerDecompileResult result); |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
diff --git a/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs b/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs index cd17f100..efd6600d 100644 --- a/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs +++ b/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs | |||
| @@ -5,36 +5,111 @@ namespace WixToolset.Extensibility.Services | |||
| 5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
| 6 | using WixToolset.Data; | 6 | using WixToolset.Data; |
| 7 | 7 | ||
| 8 | #pragma warning disable 1591 // TODO: add documentation | 8 | /// <summary> |
| 9 | /// Provides the command-line arguments. | ||
| 10 | /// </summary> | ||
| 9 | public interface ICommandLineParser | 11 | public interface ICommandLineParser |
| 10 | { | 12 | { |
| 13 | /// <summary> | ||
| 14 | /// Gets the argument that caused the error. | ||
| 15 | /// </summary> | ||
| 11 | string ErrorArgument { get; } | 16 | string ErrorArgument { get; } |
| 12 | 17 | ||
| 13 | /// <summary> | 18 | /// <summary> |
| 14 | /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity | 19 | /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity |
| 15 | /// </summary> | 20 | /// </summary> |
| 16 | /// <param name="arg">The string check.</param> | 21 | /// <param name="argument">The string check.</param> |
| 17 | /// <returns>True if a valid switch, otherwise false.</returns> | 22 | /// <returns>True if a valid switch, otherwise false.</returns> |
| 18 | bool IsSwitch(string arg); | 23 | bool IsSwitch(string argument); |
| 19 | 24 | ||
| 25 | /// <summary> | ||
| 26 | /// Gets the current argument as a file or displays an error. | ||
| 27 | /// </summary> | ||
| 28 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 29 | /// <param name="fileType">Type of file displayed in the error message if necessary.</param> | ||
| 30 | /// <returns>The fully expanded path if the argument is a file path, otherwise null.</returns> | ||
| 20 | string GetArgumentAsFilePathOrError(string argument, string fileType); | 31 | string GetArgumentAsFilePathOrError(string argument, string fileType); |
| 21 | 32 | ||
| 22 | void GetArgumentAsFilePathOrError(string argument, string fileType, IList<string> paths); | 33 | /// <summary> |
| 34 | /// Adds the current argument as a file to the list or displays an error. | ||
| 35 | /// </summary> | ||
| 36 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 37 | /// <param name="fileType">Type of file displayed in the error message if necessary.</param> | ||
| 38 | /// <param name="paths">List to add the fully expanded path if the argument is a file path.</param> | ||
| 39 | /// <returns>True if the argument is a file path, otherwise false.</returns> | ||
| 40 | bool GetArgumentAsFilePathOrError(string argument, string fileType, IList<string> paths); | ||
| 23 | 41 | ||
| 24 | string GetNextArgumentOrError(string commandLineSwitch); | 42 | /// <summary> |
| 43 | /// Gets the next argument or displays error if no argument is available. | ||
| 44 | /// </summary> | ||
| 45 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 46 | /// <returns>The next argument if present or null</returns> | ||
| 47 | string GetNextArgumentOrError(string argument); | ||
| 25 | 48 | ||
| 26 | bool GetNextArgumentOrError(string commandLineSwitch, IList<string> argument); | 49 | /// <summary> |
| 50 | /// Adds the next argument to a list or displays error if no argument is available. | ||
| 51 | /// </summary> | ||
| 52 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 53 | /// <param name="arguments">List to add the argument to.</param> | ||
| 54 | /// <returns>True if an argument is available, otherwise false.</returns> | ||
| 55 | bool GetNextArgumentOrError(string argument, IList<string> arguments); | ||
| 27 | 56 | ||
| 28 | string GetNextArgumentAsDirectoryOrError(string commandLineSwitch); | 57 | /// <summary> |
| 58 | /// Gets the next argument as a directory or displays an error. | ||
| 59 | /// </summary> | ||
| 60 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 61 | /// <returns>The fully expanded path if the argument is a directory, otherwise null.</returns> | ||
| 62 | string GetNextArgumentAsDirectoryOrError(string argument); | ||
| 29 | 63 | ||
| 30 | bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList<string> directories); | 64 | /// <summary> |
| 65 | /// Adds the next argument as a directory to the list or displays an error. | ||
| 66 | /// </summary> | ||
| 67 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 68 | /// <param name="directories">List to add the fully expanded directory if the argument is a file path.</param> | ||
| 69 | /// <returns>True if the argument is a directory, otherwise false.</returns> | ||
| 70 | bool GetNextArgumentAsDirectoryOrError(string argument, IList<string> directories); | ||
| 31 | 71 | ||
| 32 | string GetNextArgumentAsFilePathOrError(string commandLineSwitch); | 72 | /// <summary> |
| 73 | /// Gets the next argument as a file or displays an error. | ||
| 74 | /// </summary> | ||
| 75 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 76 | /// <returns>The fully expanded path if the argument is a file path, otherwise null.</returns> | ||
| 77 | string GetNextArgumentAsFilePathOrError(string argument); | ||
| 33 | 78 | ||
| 34 | bool GetNextArgumentAsFilePathOrError(string commandLineSwitch, string fileType, IList<string> paths); | 79 | /// <summary> |
| 80 | /// Adds the next argument as a file to the list or displays an error. | ||
| 81 | /// </summary> | ||
| 82 | /// <param name="argument">Current argument used in the error message if necessary.</param> | ||
| 83 | /// <param name="fileType">Type of file displayed in the error message if necessary.</param> | ||
| 84 | /// <param name="paths">List to add the fully expanded path if the argument is a file path.</param> | ||
| 85 | /// <returns>True if the argument is a file path, otherwise false.</returns> | ||
| 86 | bool GetNextArgumentAsFilePathOrError(string argument, string fileType, IList<string> paths); | ||
| 35 | 87 | ||
| 88 | /// <summary> | ||
| 89 | /// Reports a command line error for the provided argument. | ||
| 90 | /// </summary> | ||
| 91 | /// <param name="argument">Argument that caused the error.</param> | ||
| 92 | /// <param name="message">Message to report.</param> | ||
| 36 | void ReportErrorArgument(string argument, Message message = null); | 93 | void ReportErrorArgument(string argument, Message message = null); |
| 37 | 94 | ||
| 38 | bool TryGetNextSwitchOrArgument(out string arg); | 95 | /// <summary> |
| 96 | /// Tries to get the next argument. | ||
| 97 | /// </summary> | ||
| 98 | /// <param name="argument">Next argument if available.</param> | ||
| 99 | /// <returns>True if argument is available, otherwise false.</returns> | ||
| 100 | bool TryGetNextSwitchOrArgument(out string argument); | ||
| 101 | |||
| 102 | /// <summary> | ||
| 103 | /// Looks ahead to the next argument without moving to the next argument. | ||
| 104 | /// </summary> | ||
| 105 | /// <returns>Next argument if available, otherwise null.</returns> | ||
| 106 | string PeekNextArgument(); | ||
| 107 | |||
| 108 | /// <summary> | ||
| 109 | /// Tries to looks ahead to the next argument without moving to the next argument. | ||
| 110 | /// </summary> | ||
| 111 | /// <param name="argument">Argument found if present.</param> | ||
| 112 | /// <returns>True if argument is found, otherwise false.</returns> | ||
| 113 | bool TryPeekNextArgument(out string argument); | ||
| 39 | } | 114 | } |
| 40 | } | 115 | } |
