diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2017-05-18 22:41:08 +0300 |
---|---|---|
committer | Jonathan Pryor <jonpryor@vt.edu> | 2017-05-18 22:41:08 +0300 |
commit | 5077205a44a7dc97edf6b67072bea53f043cf815 (patch) | |
tree | 472611ec96872382ca501e74bc89241bd50ffa0d | |
parent | 0d6f6f8f40a2135ac7c5c01ccf9947cdb3244f0d (diff) |
[pdb2mdb] Dispose Cecil AssemblyDefinition on pdb2mdb (#4899)mono-5.0.1.12017-02
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
-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)); + } } } |