Question

I'm using Mono.Cecil to write a simple utility that looks for type/method usage within .NET assemblies (ex. calling ToString on enums).

I am able to get find the method, but it would be cool to display the source/line information to the user. Is this possible with Mono.Cecil?

Was it helpful?

Solution

It is possible. First you should read the guide from the Mono.Cecil wiki about debugging symbols.

Make sure you have Mono.Cecil.Pdb.dll near Mono.Cecil.dll, set the ReaderParameters to read the symbols as indicated in the guide, and then, instructions who have a sequence point in the pdb file will have their SequencePoint property non null, with line information available. The Document property of the SequencePoint holds the name of the source file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top