mono/roslyn — pull request #4 by DavidKarlas (2014-12-21 22:19:18+00:00)
Title: [Mdb] Mdb(Mono debug symbols file) emitting support added

First I will explain files...
* Files MonoSymbolFile.cs, MonoSymbolTable.cs, MonoSymbolWriter.cs and SourceMethodBuilder.cs are copy pastes from [mono/Mono.CompilerServices.SymbolWriter](https://github.com/mono/mono/tree/master/mcs/class/Mono.CompilerServices.SymbolWriter). There are minimal modifications like MD5 creation, opening files with PclFileAccess, added method SetMethodUnit to be able to set unit later because in ISymUnmanagedWriter2 it's not know at time of opening...
* PclFileAccess.cs file is workaround Pcl limitations to access file operations...
* PdbWriter.cs detect if we are on Mono and if we are use MdbWriter instead of pdb...
* MdbWriter.cs is implementation of ISymUnmanagedWriter2 which is basiclly just proxy between Roslyn .pdb emitting and MonoSymbolWriter.cs

Ok so... Lets list problems...
* MdbWriter is used automaticlly(always) when running on Mono and never on .Net... Could be improved with some flag like /debugformat:pdb/mdb but would require many changes in Roslyn files(problems with future merging)
* Use of reflection... "Initialize (object emitter, string filename, object ptrIStream, bool fullBuild)" call us with COMWrapped objects and so I didn't want to access stupid COM API so I just reflection extract .Net private field objects... I could probably achieve same thing without reflection(not 100% will investigate if this is problem)...
* I couldn't find way where I can access assembly GUID which must be same in MDB/PDB and assembly... I had to use reflection again to access "guidIndex" inside "writer" and fetch GUID with id 1.
* Roslyn send us Stream of PDB file and we don't use it... which creates empty(0 bytes) .pdb next to assembly and our .mdb file...
* See methods in "Used by Roslyn but not implemented" region... I'm mostly unsure about "UsingNamespace" and what is used for because some namespaces are in .mdb but Mono Runtime is not using those values...
* Also method GetDebugInfo returns 0 and I'm not sure if this is ok...
* Exception NotUsedInRoslynException is used to detect some changes if Roslyn start using some methods that we are not aware...

I tested this output with XS unit tests and all tests passed. I used a bit different version(one which removes "hidden"(0xfeefee lines) SequencePoints because MonoRuntime atm handles this seqPoints wrong(it should just ignore... will open PR on Runtime). I like to think this implementation is better then mcs.exe([Bug 25358](https://bugzilla.xamarin.com/show_bug.cgi?id=25358)) or pdb2mdb([Bug 25357](https://bugzilla.xamarin.com/show_bug.cgi?id=25357)) since this works :)