开发者

Is there a way to list all invocations and hardcoded string parameters of a method from a .Net assembly?

For example开发者_如何学运维, assume that in my assembly, in Namespace A, Class B, there is an instance method with the following signature:

void Test(string someString, int someOtherParm, string someOtherString );

This method is called multiple times, from multiple places in the assembly. I would like to be able build a list of all invocations of this method and the value of the someString/someOtherString (assuming they are hardcoded).

In other words, I like to extract a list of calls like the example one below, if they happen in the assembly somewhere:

Test("some text", 8, "some other text"); 

Thanks in advance, R.


You could use the Cecil library, which is a very powerful IL inspection and modification API. You will want to create a "method visitor" that will scan for call instructions and attempt to locate constant strings loaded onto the stack.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜