In previous release of .NET Reflector, I was able to get the namespace of an instruction (fonction/sub) inside a function but now I can't and the doc does not exist.
.NET Reflector 188.8.131.52 (last free version)
This line was working but not now : instruction.Value.declaringtype.namespace.ToString
How do I get the namespace of an instruction?
asked Apr 17, 2012 at 03:39 PM naster 7
Jason Haley posted a link to some resources that he wrote on the following forum post http://forums.reflector.net/questions/1200/using-net-reflector-api?page=1#1241
One thing to be aware of is the object model's notion of reference and declaration. For example, types can be an ITypeReference, an object that contains properties of the type such as its name and namespace, but to get the underlying type you need to use the Resolve() method to convert the ITypeReference into a ITypeDeclaration. The same applies to a IMethodReference and IMethodDeclaration. The best way to get a feeling for the model is to use Reflector on reflector looking at the reflector.CodelModel namespace.
Another is that the ITypeDeclaration can also contain nested types in the NestedTypes property.
You are probably only interested in the Value of an instruction for certain opcodes, so we might just be looking for virtual method calls in the IL stream.
We use Reflector programmatically in this way to do various things as part of our build process so the object model is really useful. We do need to do a lot more documentation of it though.
answered Apr 18, 2012 at 09:28 AM
Jason's blog post, and several other resources, are actually linked-to from our introduction to the .NET Reflector add-in model:
answered Apr 18, 2012 at 03:35 PM
answered Apr 18, 2012 at 07:44 PM