Support converting embedded Pdbs to XML#235
Support converting embedded Pdbs to XML#235KirillOsenkov wants to merge 2 commits intodotnet:mainfrom
Conversation
|
The APIs I needed weren't public. Maybe I missed something? Feel free to push directly to the PR branch to fix. |
|
I'm sorry, I don't quite understand how to use the link you provided to get rid of reflection here. My task is given a |
|
I see. You can use MetadataReader.MetadataPointer and MetadataReader.Length to read the data. |
|
I'm sorry again, I'm not well-versed in pointers and unsafe code, so I really don't know how to do this. It would be great if you could just do it yourself when you have time (not urgent). |
|
I think PEReader should be able to read from an RVA given the position and size, and fill a byte array. Not sure if disk layout/memory layout of the PE format is relevant here. |
| var embeddedProvider = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry); | ||
| var memoryBlock = embeddedProvider.GetType().GetMethod("GetMetadataBlock", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(embeddedProvider, null); | ||
| var memoryBlockType = memoryBlock.GetType(); | ||
| var size = (int)memoryBlockType.GetProperty("Size").GetValue(memoryBlock); | ||
| var bytes = (ImmutableArray<byte>)memoryBlockType.GetMethod("GetContentUnchecked").Invoke(memoryBlock, new object[] { 0, size }); | ||
| pdbStream = new MemoryStream(bytes.ToArray()); |
There was a problem hiding this comment.
var pdbStream = new UnmanagedMemoryStream(reader.MetadataPointer, reader.MetadataLength, reader.MetadataLength, FileAccess.Read);
No description provided.