Fix Crossgen2 PDB generator (#70407)
* Fix Crossgen2 PDB generator
During my perf investigation work I have found out that PDB emitter
in Crossgen2 is broken. I tracked this down to the change
https://github.com/dotnet/runtime/commit/
fdf6485c800ec580656d7491795e10881d493afb#diff-24e48862e3b82f52e7fa04f22700b1c976a012bfeb08a246406f4e5ec579699b
that caused two behavioral changes in the PDB emitter:
1) The logic around QueryPDBNameEx got refactored to use a char[]
instead of a StringBuilder and that silently caused _pdbFilePath
to be set to the string "System.Char[]" instead of the actual path
(cf PdbWriter.cs#221 in the quoted commit).
2) The COM wrapper refactoring ended up bumping the refcount
on the _ngenWriter by one so that it never got actually closed
and properly flushed; due to this the resulting PDB was invalid.
Thanks
Tomas