From add525424e44a050d3f98f64e56a85ab5d79955d Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 13 Feb 2020 14:28:58 -0500 Subject: Make BindResult disposable to manage WixOutput disposability. --- .../Bind/BindDatabaseCommand.cs | 55 ++++++---------------- 1 file changed, 15 insertions(+), 40 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 1bcaf209..a90517da 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -17,13 +17,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Binds a databse. /// - internal class BindDatabaseCommand : IDisposable + internal class BindDatabaseCommand { // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs. internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}"); - private bool disposed; - public BindDatabaseCommand(IBindContext context, IEnumerable backendExtension, Validator validator):this(context, backendExtension, null, validator) { } @@ -97,13 +95,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private Validator Validator { get; } - public IEnumerable FileTransfers { get; private set; } - - public IEnumerable TrackedFiles { get; private set; } - - public WixOutput Wixout { get; private set; } - - public void Execute() + public IBindResult Execute() { var section = this.Intermediate.Sections.Single(); @@ -218,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (this.Messaging.EncounteredError) { - return; + return null; } // Call extension @@ -290,7 +282,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // stop processing if an error previously occurred if (this.Messaging.EncounteredError) { - return; + return null; } // Gather information about files that do not come from merge modules. @@ -322,7 +314,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // stop processing if an error previously occurred if (this.Messaging.EncounteredError) { - return; + return null; } // Now that the variable cache is populated, resolve any delayed fields. @@ -347,7 +339,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // stop processing if an error previously occurred if (this.Messaging.EncounteredError) { - return; + return null; } // Time to create the output object. Try to put as much above here as possible, updating the IR is better. @@ -425,7 +417,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Stop processing if an error previously occurred. if (this.Messaging.EncounteredError) { - return; + return null; } // Ensure the intermediate folder is created since delta patches will be @@ -479,7 +471,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // stop processing if an error previously occurred if (this.Messaging.EncounteredError) { - return; + return null; } // Generate database file. @@ -496,7 +488,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Stop processing if an error previously occurred. if (this.Messaging.EncounteredError) { - return; + return null; } // Merge modules. @@ -533,7 +525,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (this.Messaging.EncounteredError) { - return; + return null; } #if TODO_FINISH_VALIDATION @@ -580,10 +572,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.SourcePath, TrackedFileType.Input, f.SourceLineNumber))); } - this.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output); + var result = this.ServiceProvider.GetService(); + result.FileTransfers = fileTransfers; + result.TrackedFiles = trackedFiles; + result.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output); - this.FileTransfers = fileTransfers; - this.TrackedFiles = trackedFiles; + return result; } private WixOutput CreateWixout(List trackedFiles, Intermediate intermediate, WindowsInstallerData output) @@ -984,24 +978,5 @@ namespace WixToolset.Core.WindowsInstaller.Bind return command.GeneratedTemporaryFiles; } - -#region IDisposable Support - - public void Dispose() => this.Dispose(true); - - protected virtual void Dispose(bool disposing) - { - if (!this.disposed) - { - if (disposing) - { - this.Wixout?.Dispose(); - } - - this.disposed = true; - } - } - -#endregion } } -- cgit v1.2.3-55-g6feb