Debugger Visualizer for MethodInfo, DynamicMethod, and MethodBase available for download

When I was preparing (still am) for my TechEd talk about Reflection 2.0, one of the coolest things I found was this nice DynamicMethod visualizer posted as a code sample.
 
Taking apart the code for this project was a blast, and I learned many interesting things. I set out to create a new version of this Debugger Visualizer that also supports visualizing MethodInfo objects, not just Dynamic Methods (Code generated on the fly).
 
Here's the result:
 
Sample shots:
 
Visualizing a MethodInfo object:
 
 
 
 
 
Visualizing a DynamicMethod object (the original ability for the code):
 
 
 
The source can help you learn how to:
  • Get the IL byte stream from any MethodBase-based object
  • Parse IL into understandable chunks
  • Write a visualizer
  • Resolve strings, methods and types from static Tokens in the IL code (see StaticResolver class)
  • Understand IL Opcodes and what they stand for
Have fun, geeks!
Published Tuesday, April 25, 2006 10:01 PM by RoyOsherove
Filed under: ,

Comments

Thursday, August 03, 2006 1:38 AM by Scott Hanselman's Computer Zen

# Hanselminutes Podcast 27 - Reflection

Thursday, August 03, 2006 7:35 AM by David's blog

# Note to Self: HanselMinutes #27: Reflection

Sunday, November 05, 2006 10:55 PM by Adityanand Pasumarthi

# How to re-create a MethodInfo from IL stream

Hi, The information you provided has been very useful for me. I have one problem for which I'm trying to find solution. Can you please help me out? Here is my problem. "I have a MethodInfo object on a method. I took the IL byte array from it using MethodBody.GetILStream. I want to use this IL stream to re-create this method in a dynamic type, which I want to create using MethodBuilder." I tried it and I thought I achieved it using SwapMethodBody, but when I replace the IL stream of my dynamic type's method with the one I gotfrom my regular method, and try to invoke the method on the dynamic type, I'm getting "InvalidProgramException". This exception occurs if the IL is not correct within the method. I inspected the IL for both the methods and it looks slightly different. Can you please suggest a good solution to my problem (described in double quotes above). Regards, Aditya.P
Friday, March 07, 2008 7:14 PM by Haibo Luo's weblog

# Take Two: IL Visualizer

I was glad to hear many positive feedbacks about the DebuggerVisualizer for DynamicMethod ; on the sad

# Light-weight Code Gen « Blog for JsonExSerializer Project

Pingback from  Light-weight Code Gen « Blog for JsonExSerializer Project