开发者

How to get source/line number for IL instruction using Mono.Cecil

I'm using Mono.Cecil to write a simple utili开发者_StackOverflow社区ty 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜