aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2023-06-15 15:40:37 -0400
committerBob Arnson <github@bobs.org>2023-07-13 17:51:54 -0400
commitcef14c6055f85e470ff9ce7a33b53e80d1160ba6 (patch)
treec0fa96c514ab6eb0e152191928191fd42d7ecc03
parent164c29aff8d6581a3277c9fd0810ea56356c3e69 (diff)
downloadwix-cef14c6055f85e470ff9ce7a33b53e80d1160ba6.tar.gz
wix-cef14c6055f85e470ff9ce7a33b53e80d1160ba6.tar.bz2
wix-cef14c6055f85e470ff9ce7a33b53e80d1160ba6.zip
Ensure extensions get the same decompiler helper.
Fixes https://github.com/wixtoolset/issues/issues/7548. THIS IS A BREAKING INTERFACE/EXTENSIBILITY CHANGE.
-rw-r--r--src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerDecompilerExtension.cs6
-rw-r--r--src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs4
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs13
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/WixToolsetCoreServiceProviderExtensions.cs15
4 files changed, 15 insertions, 23 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerDecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerDecompilerExtension.cs
index 8072cd88..69124490 100644
--- a/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerDecompilerExtension.cs
+++ b/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerDecompilerExtension.cs
@@ -36,13 +36,13 @@ namespace WixToolset.Extensibility
36 /// <summary> 36 /// <summary>
37 /// See <see cref="IWindowsInstallerDecompilerExtension.PostDecompile(IWindowsInstallerDecompileResult)"/> 37 /// See <see cref="IWindowsInstallerDecompilerExtension.PostDecompile(IWindowsInstallerDecompileResult)"/>
38 /// </summary> 38 /// </summary>
39 public virtual void PreDecompile(IWindowsInstallerDecompileContext context) 39 public virtual void PreDecompile(IWindowsInstallerDecompileContext context, IWindowsInstallerDecompilerHelper helper)
40 { 40 {
41 this.Context = context; 41 this.Context = context;
42 42
43 this.Messaging = context.ServiceProvider.GetService<IMessaging>(); 43 this.DecompilerHelper = helper;
44 44
45 this.DecompilerHelper = context.ServiceProvider.GetService<IWindowsInstallerDecompilerHelper>(); 45 this.Messaging = context.ServiceProvider.GetService<IMessaging>();
46 } 46 }
47 47
48 /// <summary> 48 /// <summary>
diff --git a/src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs
index f7d54799..cbeda116 100644
--- a/src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs
+++ b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerDecompilerExtension.cs
@@ -5,6 +5,7 @@ namespace WixToolset.Extensibility
5 using System.Collections.Generic; 5 using System.Collections.Generic;
6 using WixToolset.Data.WindowsInstaller; 6 using WixToolset.Data.WindowsInstaller;
7 using WixToolset.Extensibility.Data; 7 using WixToolset.Extensibility.Data;
8 using WixToolset.Extensibility.Services;
8 9
9 /// <summary> 10 /// <summary>
10 /// Interface all windows installer decompiler extensions implement. 11 /// Interface all windows installer decompiler extensions implement.
@@ -21,7 +22,8 @@ namespace WixToolset.Extensibility
21 /// Called before decompiling occurs. 22 /// Called before decompiling occurs.
22 /// </summary> 23 /// </summary>
23 /// <param name="context">Decompile context.</param> 24 /// <param name="context">Decompile context.</param>
24 void PreDecompile(IWindowsInstallerDecompileContext context); 25 /// <param name="helper">Decompile helper.</param>
26 void PreDecompile(IWindowsInstallerDecompileContext context, IWindowsInstallerDecompilerHelper helper);
25 27
26 /// <summary> 28 /// <summary>
27 /// Called before decompiling occurs. 29 /// Called before decompiling occurs.
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs
index fb560d1c..267fe495 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerDecompiler.cs
@@ -39,16 +39,18 @@ namespace WixToolset.Core.WindowsInstaller
39 context.SymbolDefinitionCreator = this.ServiceProvider.GetService<ISymbolDefinitionCreator>(); 39 context.SymbolDefinitionCreator = this.ServiceProvider.GetService<ISymbolDefinitionCreator>();
40 } 40 }
41 41
42 var decompilerHelper = context.ServiceProvider.GetService<IWindowsInstallerDecompilerHelper>();
43
42 // Pre-decompile. 44 // Pre-decompile.
43 // 45 //
44 foreach (var extension in context.Extensions) 46 foreach (var extension in context.Extensions)
45 { 47 {
46 extension.PreDecompile(context); 48 extension.PreDecompile(context, decompilerHelper);
47 } 49 }
48 50
49 // Decompile. 51 // Decompile.
50 // 52 //
51 var result = this.Execute(context); 53 var result = this.Execute(context, decompilerHelper);
52 54
53 if (result != null) 55 if (result != null)
54 { 56 {
@@ -63,7 +65,7 @@ namespace WixToolset.Core.WindowsInstaller
63 return result; 65 return result;
64 } 66 }
65 67
66 private IWindowsInstallerDecompileResult Execute(IWindowsInstallerDecompileContext context) 68 private IWindowsInstallerDecompileResult Execute(IWindowsInstallerDecompileContext context, IWindowsInstallerDecompilerHelper decompilerHelper)
67 { 69 {
68 // Delete the directory and its files to prevent cab extraction failure due to an existing file. 70 // Delete the directory and its files to prevent cab extraction failure due to an existing file.
69 if (!String.IsNullOrEmpty(context.ExtractFolder) && Directory.Exists(context.ExtractFolder)) 71 if (!String.IsNullOrEmpty(context.ExtractFolder) && Directory.Exists(context.ExtractFolder))
@@ -83,11 +85,11 @@ namespace WixToolset.Core.WindowsInstaller
83 } 85 }
84 else 86 else
85 { 87 {
86 return this.DecompileDatabase(context, backendHelper, fileSystem, pathResolver); 88 return this.DecompileDatabase(context, decompilerHelper, backendHelper, fileSystem, pathResolver);
87 } 89 }
88 } 90 }
89 91
90 private IWindowsInstallerDecompileResult DecompileDatabase(IWindowsInstallerDecompileContext context, IWindowsInstallerBackendHelper backendHelper, IFileSystem fileSystem, IPathResolver pathResolver) 92 private IWindowsInstallerDecompileResult DecompileDatabase(IWindowsInstallerDecompileContext context, IWindowsInstallerDecompilerHelper decompilerHelper, IWindowsInstallerBackendHelper backendHelper, IFileSystem fileSystem, IPathResolver pathResolver)
91 { 93 {
92 var extractFilesFolder = context.SuppressExtractCabinets || (String.IsNullOrEmpty(context.CabinetExtractFolder) && String.IsNullOrEmpty(context.ExtractFolder)) ? null : 94 var extractFilesFolder = context.SuppressExtractCabinets || (String.IsNullOrEmpty(context.CabinetExtractFolder) && String.IsNullOrEmpty(context.ExtractFolder)) ? null :
93 String.IsNullOrEmpty(context.CabinetExtractFolder) ? Path.Combine(context.ExtractFolder, "File") : context.CabinetExtractFolder; 95 String.IsNullOrEmpty(context.CabinetExtractFolder) ? Path.Combine(context.ExtractFolder, "File") : context.CabinetExtractFolder;
@@ -106,7 +108,6 @@ namespace WixToolset.Core.WindowsInstaller
106 var output = unbindCommand.Execute(); 108 var output = unbindCommand.Execute();
107 var extractedFilePaths = unbindCommand.ExportedFiles; 109 var extractedFilePaths = unbindCommand.ExportedFiles;
108 110
109 var decompilerHelper = context.ServiceProvider.GetService<IWindowsInstallerDecompilerHelper>();
110 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); 111 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);
111 var document = decompiler.Decompile(output); 112 var document = decompiler.Decompile(output);
112 113
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/WixToolsetCoreServiceProviderExtensions.cs b/src/wix/WixToolset.Core.WindowsInstaller/WixToolsetCoreServiceProviderExtensions.cs
index c085af9b..ea049598 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/WixToolsetCoreServiceProviderExtensions.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/WixToolsetCoreServiceProviderExtensions.cs
@@ -2,8 +2,6 @@
2 2
3namespace WixToolset.Core.WindowsInstaller 3namespace WixToolset.Core.WindowsInstaller
4{ 4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Core.WindowsInstaller.ExtensibilityServices; 5 using WixToolset.Core.WindowsInstaller.ExtensibilityServices;
8 using WixToolset.Extensibility.Data; 6 using WixToolset.Extensibility.Data;
9 using WixToolset.Extensibility.Services; 7 using WixToolset.Extensibility.Services;
@@ -30,20 +28,11 @@ namespace WixToolset.Core.WindowsInstaller
30 28
31 private static void AddServices(IWixToolsetCoreServiceProvider coreProvider) 29 private static void AddServices(IWixToolsetCoreServiceProvider coreProvider)
32 { 30 {
33 // Singletons.
34 coreProvider.AddService((provider, singletons) => AddSingleton<IWindowsInstallerBackendHelper>(singletons, new WindowsInstallerBackendHelper(provider)));
35 coreProvider.AddService((provider, singletons) => AddSingleton<IWindowsInstallerDecompilerHelper>(singletons, new WindowsInstallerDecompilerHelper(provider)));
36
37 // Transients.
38 coreProvider.AddService<IWindowsInstallerDecompiler>((provider, singletons) => new WindowsInstallerDecompiler(provider)); 31 coreProvider.AddService<IWindowsInstallerDecompiler>((provider, singletons) => new WindowsInstallerDecompiler(provider));
32 coreProvider.AddService<IWindowsInstallerDecompilerHelper>((provider, singletons) => new WindowsInstallerDecompilerHelper(provider));
39 coreProvider.AddService<IWindowsInstallerDecompileContext>((provider, singletons) => new WindowsInstallerDecompileContext(provider)); 33 coreProvider.AddService<IWindowsInstallerDecompileContext>((provider, singletons) => new WindowsInstallerDecompileContext(provider));
40 coreProvider.AddService<IWindowsInstallerDecompileResult>((provider, singletons) => new WindowsInstallerDecompileResult()); 34 coreProvider.AddService<IWindowsInstallerDecompileResult>((provider, singletons) => new WindowsInstallerDecompileResult());
41 } 35 coreProvider.AddService<IWindowsInstallerBackendHelper>((provider, singletons) => new WindowsInstallerBackendHelper(provider));
42
43 private static T AddSingleton<T>(Dictionary<Type, object> singletons, T service) where T : class
44 {
45 singletons.Add(typeof(T), service);
46 return service;
47 } 36 }
48 } 37 }
49} 38}