1

I am doing some long-winded code generation at run-time using expression trees. But once I've done the Expression.Lambda<Foo>(methodBody, objArg).Compile() everything is turned into a black box. I am wondering, what is the best approach and tools to

  1. Debug in case something fails? I haven't found a way to step-debug my code
  2. Get an overview of the generated IL
Carlo V. Dango
  • 13,322
  • 16
  • 71
  • 114
  • 2
    For point 2. you can use the [ILDasm](http://msdn.microsoft.com/en-us/library/f7dy01k1%28v=vs.110%29.aspx) tool from Microsoft. A code-aproach is described in this [SO answer](http://stackoverflow.com/questions/6574858/convert-c-sharp-code-to-il-code). – keenthinker Mar 23 '14 at 15:54
  • 1
    ...and maybe [Cecil.Mono](http://mono-project.com/Cecil) - AFAIK LINQPad is using it and my guess is for the disassembly of the code. Also this MSDN article: [Debugging Expression trees](http://msdn.microsoft.com/en-us/library/ee725345.aspx) - in VS2010 there was an example *expression tree visualizer* and in VS2012 the tool is build-in. – keenthinker Mar 23 '14 at 16:04
  • 1
    [This answer](http://stackoverflow.com/a/4764705/622391) suggests adding your lambda to a dynamic assembly, which you then dump to a dll and view with a disassembler. Also, you can use the [IL Visualiser](http://stackoverflow.com/a/4764645/622391) from MSDN for a live (debug) IL view. – Simon MᶜKenzie Apr 08 '14 at 06:42

0 Answers0