diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2017-05-18 22:41:08 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2017-05-18 22:42:16 +0300 |
commit | bb48bbd23ddf71892a87c8c65fe7ddcc44b2debb (patch) | |
tree | f5a4a8734349a90f7a3239e3617d159d41b11c00 /mcs | |
parent | 8a3993fbcc3b48b3b966a7544124b476a9d2f1d5 (diff) |
[pdb2mdb] Dispose Cecil AssemblyDefinition on pdb2mdb (#4899)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=56275
Recent Cecil 0.10 changed to not reading the assembly in memory but
instead reads directly from the underlying stream [0]. This however
means that the file handle is not freed until the AssemblyDefinition
is disposed.
Xamarin.Android is using the pdb2mdb source as part of
Xamarin.Android.Build.Tasks.dll and hit an issue where the file
would be locked inside of VS.
[0] http://cecil.pe/post/149243207656/mono-cecil-010-beta-1
(cherry picked from commit 5077205a44a7dc97edf6b67072bea53f043cf815)
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/tools/pdb2mdb/Driver.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/mcs/tools/pdb2mdb/Driver.cs b/mcs/tools/pdb2mdb/Driver.cs index 5aa1fcf0b5b..70395034075 100644 --- a/mcs/tools/pdb2mdb/Driver.cs +++ b/mcs/tools/pdb2mdb/Driver.cs @@ -28,20 +28,21 @@ namespace Pdb2Mdb { public static void Convert (string filename) { - var asm = AssemblyDefinition.ReadAssembly (filename); + using (var asm = AssemblyDefinition.ReadAssembly (filename)) { - var pdb = asm.Name.Name + ".pdb"; - pdb = Path.Combine (Path.GetDirectoryName (filename), pdb); + var pdb = asm.Name.Name + ".pdb"; + pdb = Path.Combine (Path.GetDirectoryName (filename), pdb); - if (!File.Exists (pdb)) - throw new FileNotFoundException ("PDB file doesn't exist: " + pdb); + if (!File.Exists (pdb)) + throw new FileNotFoundException ("PDB file doesn't exist: " + pdb); - using (var stream = File.OpenRead (pdb)) { - if (IsPortablePdb (stream)) - throw new PortablePdbNotSupportedException (); + using (var stream = File.OpenRead (pdb)) { + if (IsPortablePdb (stream)) + throw new PortablePdbNotSupportedException (); - var funcs = PdbFile.LoadFunctions (stream, true); - Converter.Convert (asm, funcs, new MonoSymbolWriter (filename)); + var funcs = PdbFile.LoadFunctions (stream, true); + Converter.Convert (asm, funcs, new MonoSymbolWriter (filename)); + } } } |