Refactor dispose into finally to make debugging easier.
Sean Hall committed
Apr 3, 2020 at 11:37 UTC
37356647817b72a336eeedaa7472e268a04054c8
1 file changed
+7
-3
src/WixToolset.Core.WindowsInstaller/MsiBackend.cs
+7
-3
@@ -26,6 +26,7 @@ namespace WixToolset.Core.WindowsInstaller
26
var validator = Validator.CreateFromContext(context, "darice.cub");
27
28
IBindResult result = null;
29
+ var dispose = true;
30
try
31
{
32
var command = new BindDatabaseCommand(context, backendExtensions, validator);
@@ -36,12 +37,15 @@ namespace WixToolset.Core.WindowsInstaller
37
extension.PostBackendBind(result);
38
}
39
40
+ dispose = false;
41
return result;
42
}
41
- catch
43
+ finally
44
{
43
- result?.Dispose();
44
- throw;
45
+ if (dispose)
46
+ {
47
+ result?.Dispose();
48
+ }
49
}
50
}
51