Hi,
I have several special methods, and I want analyze they calls in compiled assembly.
Example:
public static class SrcHelper {
[MySpecialMethod]
[Conditional( "DEBUG" )]
public static void ToDo( params object[] info ) {
/* do nothing */
/* this method is not called when code is compiled in RELEASE mode */
}
}
// ... somewhere else in another assembly ...
Array CreateArraySampleMethod( int size ) {
// This call has only informative character. No functionality is required.
SrcHelper.ToDo( "Should create array of ", typeof( MyClass ), " with specified size." );
throw new NotImplementedException();
}
From this compiled code I want get the argument values { "Should create array of ", MyClass, " with specified size." }. I tried use Cecil from Mono, and I found the instructions for call "ToDo" method. But now am I confused how to identify instruction with argument values.
I know, there can be complex situation, and some argument's value can not be resolved. But I need resolve only constant values - it's enough for my purpose.
Thanks.
EDIT: The "ToDo" method (and similar ones) should be used as alternative to comments ( //, /* ... */ ), and after compilation, should be IL analyzed and autogenerated documentation and todo-list for concrete assembly.