Debugger Visualizers for MethodInfo, DynamicMethod, and MethodBase
Oren's post about DynamicMethods in Reflection is a great "advanced" intro to the idea of DyamicMethod (a method you can create on the fly and then cache to execute many times - great of optimization scenarios over multiple objects).
My last talk at TechEd Europe this year will be about "Deep Reflection". It is a variant of a session I did at TechEd Israel and one of the topics I cover there is the use of DyanmicMethods.
One of the things that I also show there is how you may be able to create a DyamicMethod and MethodInfo Visualizer, that shows you the IL produced in the method as you create it. Very powerful if you want to debug code generated at runtime.
Here's a screenshot of the visualizer at work over a MethodInfo object. It will work just as well on a DynamicMethod object:
You can download the visualizers for these here:
- DynamicMethod and MethodInfo visualizers (VS 2005 and VS 2008 bin versions)
- The original post that also has links to the source code
* possible cool thing you can do: Use RunSharp when generating the IL inside a DynamicMethod. I'm not sure it's possible but I'll check and maybe present this.