From 64750a8dd105d89c27613694e1008a454df2a4ee Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 10 Mar 2022 14:18:34 -0800 Subject: Remove Unbind as backend function Unbinding is not a general purpose function as initially imagined. --- .../Data/IUnbindContext.cs | 24 ------ src/api/wix/WixToolset.Extensibility/IBackend.cs | 13 ++- .../WixToolset.Extensibility/IBackendFactory.cs | 11 ++- .../WixToolset.Extensibility/IUnbinderExtension.cs | 18 ---- src/wix/WixToolset.Core.Burn/BundleBackend.cs | 1 - .../WixToolset.Core.WindowsInstaller/MsiBackend.cs | 5 -- .../WixToolset.Core.WindowsInstaller/MsmBackend.cs | 5 -- .../Unbind/UnbindMsiOrMsmCommand.cs | 11 --- src/wix/WixToolset.Core/IUnbinder.cs | 12 --- src/wix/WixToolset.Core/UnbindContext.cs | 29 ------- src/wix/WixToolset.Core/Unbinder.cs | 99 ---------------------- .../WixToolset.Core/WixToolsetServiceProvider.cs | 2 - .../BundleExtractionFixture.cs | 4 - 13 files changed, 19 insertions(+), 215 deletions(-) delete mode 100644 src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs delete mode 100644 src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs delete mode 100644 src/wix/WixToolset.Core/IUnbinder.cs delete mode 100644 src/wix/WixToolset.Core/UnbindContext.cs delete mode 100644 src/wix/WixToolset.Core/Unbinder.cs diff --git a/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs deleted file mode 100644 index 6427422f..00000000 --- a/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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; - -#pragma warning disable 1591 // TODO: add documentation - public interface IUnbindContext - { - IServiceProvider ServiceProvider { get; } - - string ExportBasePath { get; set; } - - string InputFilePath { get; set; } - - string IntermediateFolder { get; set; } - - bool IsAdminImage { get; set; } - - bool SuppressDemodularization { get; set; } - - bool SuppressExtractCabinets { get; set; } - } -} \ No newline at end of file diff --git a/src/api/wix/WixToolset.Extensibility/IBackend.cs b/src/api/wix/WixToolset.Extensibility/IBackend.cs index be8406e4..cb151e05 100644 --- a/src/api/wix/WixToolset.Extensibility/IBackend.cs +++ b/src/api/wix/WixToolset.Extensibility/IBackend.cs @@ -2,16 +2,21 @@ namespace WixToolset.Extensibility { - using WixToolset.Data; using WixToolset.Extensibility.Data; -#pragma warning disable 1591 // TODO: add documentation + /// + /// Interface all backends implement. + /// public interface IBackend { + /// + /// Bind the intermediate into the final output. + /// + /// Bind context. + /// Result of the bind operation. IBindResult Bind(IBindContext context); +#pragma warning disable 1591 // TODO: add documentation IDecompileResult Decompile(IDecompileContext context); - - Intermediate Unbind(IUnbindContext context); } } diff --git a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs index 99a6704f..7f9ef62d 100644 --- a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs +++ b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs @@ -2,9 +2,18 @@ namespace WixToolset.Extensibility { -#pragma warning disable 1591 // TODO: add documentation + /// + /// Implemented by extensions to create backends. + /// public interface IBackendFactory { + /// + /// Called to find the backend used to produce the requested output type. + /// + /// Type of output being created. + /// Path to the output to create. + /// The backend for the output. + /// True if the backend was created, otherwise false. bool TryCreateBackend(string outputType, string outputPath, out IBackend backend); } } diff --git a/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs b/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs deleted file mode 100644 index 0e9a2504..00000000 --- a/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 System; - using WixToolset.Data; - - /// - /// Base class for creating an unbinder extension. - /// - public interface IUnbinderExtension - { - /// - /// Called during the generation of sectionIds for an admin image. - /// - void GenerateSectionIds(Intermediate output); - } -} diff --git a/src/wix/WixToolset.Core.Burn/BundleBackend.cs b/src/wix/WixToolset.Core.Burn/BundleBackend.cs index fa66ab1f..e248bc67 100644 --- a/src/wix/WixToolset.Core.Burn/BundleBackend.cs +++ b/src/wix/WixToolset.Core.Burn/BundleBackend.cs @@ -5,7 +5,6 @@ namespace WixToolset.Core.Burn using System; using System.IO; using WixToolset.Core.Burn.Bundles; - using WixToolset.Core.Burn.Inscribe; using WixToolset.Data; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; diff --git a/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs b/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs index 628ad8de..d1c1d3a6 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs @@ -69,10 +69,5 @@ namespace WixToolset.Core.WindowsInstaller return result; } - - public Intermediate Unbind(IUnbindContext context) - { - throw new NotImplementedException(); - } } } diff --git a/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs b/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs index 01e3c6d8..ea008c39 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs @@ -65,10 +65,5 @@ namespace WixToolset.Core.WindowsInstaller return result; } - - public Intermediate Unbind(IUnbindContext context) - { - throw new NotImplementedException(); - } } } diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs index 82015cf2..8070d42d 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs @@ -7,7 +7,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind using WixToolset.Core.Native.Msi; using WixToolset.Data; using WixToolset.Data.WindowsInstaller; - using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; internal class UnbindMsiOrMsmCommand @@ -24,16 +23,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind this.SuppressExtractCabinets = suppressExtractCabinets; } - public UnbindMsiOrMsmCommand(IUnbindContext context) - { - this.Messaging = context.ServiceProvider.GetService(); - this.DatabasePath = context.InputFilePath; - this.ExportBasePath = context.ExportBasePath; - this.IntermediateFolder = context.IntermediateFolder; - this.IsAdminImage = context.IsAdminImage; - this.SuppressDemodularization = context.SuppressDemodularization; - } - private IMessaging Messaging { get; } private IBackendHelper BackendHelper { get; } diff --git a/src/wix/WixToolset.Core/IUnbinder.cs b/src/wix/WixToolset.Core/IUnbinder.cs deleted file mode 100644 index 2b4daaa5..00000000 --- a/src/wix/WixToolset.Core/IUnbinder.cs +++ /dev/null @@ -1,12 +0,0 @@ -// 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.Core -{ - using WixToolset.Data; - -#pragma warning disable 1591 // TODO: add documentation, move into Extensibility - public interface IUnbinder - { - Intermediate Unbind(string file, OutputType outputType, string exportBasePath); - } -} diff --git a/src/wix/WixToolset.Core/UnbindContext.cs b/src/wix/WixToolset.Core/UnbindContext.cs deleted file mode 100644 index c3817a08..00000000 --- a/src/wix/WixToolset.Core/UnbindContext.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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.Core -{ - using System; - using WixToolset.Extensibility.Data; - - internal class UnbindContext : IUnbindContext - { - internal UnbindContext(IServiceProvider serviceProvider) - { - this.ServiceProvider = serviceProvider; - } - - public IServiceProvider ServiceProvider { get; } - - public string ExportBasePath { get; set; } - - public string InputFilePath { get; set; } - - public string IntermediateFolder { get; set; } - - public bool IsAdminImage { get; set; } - - public bool SuppressExtractCabinets { get; set; } - - public bool SuppressDemodularization { get; set; } - } -} diff --git a/src/wix/WixToolset.Core/Unbinder.cs b/src/wix/WixToolset.Core/Unbinder.cs deleted file mode 100644 index 3ef77083..00000000 --- a/src/wix/WixToolset.Core/Unbinder.cs +++ /dev/null @@ -1,99 +0,0 @@ -// 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.Core -{ - using System; - using System.Collections.Generic; - using System.IO; - using WixToolset.Data; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Services; - - /// - /// Unbinder core of the WiX toolset. - /// - internal sealed class Unbinder : IUnbinder - { - public Unbinder(IServiceProvider serviceProvider) - { - this.ServiceProvider = serviceProvider; - - var extensionManager = this.ServiceProvider.GetService(); - this.BackendFactories = extensionManager.GetServices(); - } - - public IServiceProvider ServiceProvider { get; } - - public IEnumerable BackendFactories { get; } - - /// - /// Gets or sets whether the input msi is an admin image. - /// - /// Set to true if the input msi is part of an admin image. - public bool IsAdminImage { get; set; } - - /// - /// Gets or sets the option to suppress demodularizing values. - /// - /// The option to suppress demodularizing values. - public bool SuppressDemodularization { get; set; } - - /// - /// Gets or sets the option to suppress extracting cabinets. - /// - /// The option to suppress extracting cabinets. - public bool SuppressExtractCabinets { get; set; } - - /// - /// Gets or sets the temporary path for the Binder. If left null, the binder - /// will use %TEMP% environment variable. - /// - /// Path to temp files. - public string TempFilesLocation => Path.GetTempPath(); - - /// - /// Unbind a Windows Installer file. - /// - /// The Windows Installer file. - /// The type of output to create. - /// The path where files should be exported. - /// The output representing the database. - public Intermediate Unbind(string file, OutputType outputType, string exportBasePath) - { - if (!File.Exists(file)) - { - if (OutputType.Transform == outputType) - { - throw new WixException(ErrorMessages.FileNotFound(null, file, "Transform")); - } - else - { - throw new WixException(ErrorMessages.FileNotFound(null, file, "Database")); - } - } - - // if we don't have the temporary files object yet, get one - Directory.CreateDirectory(this.TempFilesLocation); // ensure the base path is there - - var context = new UnbindContext(this.ServiceProvider); - context.InputFilePath = file; - context.ExportBasePath = exportBasePath; - context.IntermediateFolder = this.TempFilesLocation; - context.IsAdminImage = this.IsAdminImage; - context.SuppressDemodularization = this.SuppressDemodularization; - context.SuppressExtractCabinets = this.SuppressExtractCabinets; - - foreach (var factory in this.BackendFactories) - { - if (factory.TryCreateBackend(outputType.ToString(), file, out var backend)) - { - return backend.Unbind(context); - } - } - - // TODO: Display message that could not find a unbinder for output type? - - return null; - } - } -} diff --git a/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs b/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs index 06dbdfae..a74ba6b3 100644 --- a/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs +++ b/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs @@ -41,7 +41,6 @@ namespace WixToolset.Core this.AddService((provider, singletons) => new BindContext(provider)); this.AddService((provider, singletons) => new DecompileContext(provider)); this.AddService((provider, singletons) => new LayoutContext(provider)); - this.AddService((provider, singletons) => new UnbindContext(provider)); this.AddService((provider, singletons) => new BindFileWithPath()); this.AddService((provider, singletons) => new BindPath()); @@ -64,7 +63,6 @@ namespace WixToolset.Core this.AddService((provider, singletons) => new Librarian(provider)); this.AddService((provider, singletons) => new Linker(provider)); this.AddService((provider, singletons) => new Resolver(provider)); - this.AddService((provider, singletons) => new Unbinder(provider)); this.AddService((provider, singletons) => new LocalizationParser(provider)); this.AddService((provider, singletons) => new VariableResolver(provider)); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs index 0e056c29..5a5a52d3 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs @@ -47,11 +47,7 @@ namespace WixToolsetTest.CoreIntegration Assert.True(File.Exists(exePath)); - var unbinder = serviceProvider.GetService(); - unbinder.Unbind(exePath, OutputType.Bundle, extractFolderPath); - Assert.True(File.Exists(Path.Combine(baFolderPath, "manifest.xml"))); - Assert.False(Directory.Exists(attachedContainerFolderPath)); } } } -- cgit v1.2.3-55-g6feb