10

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?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
Filip Frącz
  • 5,881
  • 11
  • 45
  • 67

1 Answers1

18

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.

Jb Evain
  • 17,319
  • 2
  • 67
  • 67
  • 1
    Thanks - that did it! I got confused that not all instructions have SequencePoint but when you think about it, it makes sense. Thank you again :) – Filip Frącz Sep 21 '11 at 18:03