views:

155

answers:

1

Previous questions have asked if it is possible to turn compiled delegates into expression trees, for example:

The sane answers at the time were:

  • It's possible, but very hard and there's no standard library solution.
  • Use Reflector!

But fortunately there are some greatly-insane/insanely-great people out there who like reverse engineering things, and they make difficult things easy for the rest of us.

Clearly it is possible to decompile IL to C#, as Reflector does it, and so you could in principle instead target CLR 4.0 expression trees with support for all statement types. This is interesting because it wouldn't matter if the compiler's built-in special support for Expression<> lambdas is never extended to support building statement expression trees in the compiler. A library solution could fill the gap. We would then have a high-level starting point for writing aspect-like manipulations of code without having to mess with raw IL.

As noted in the answers to the above linked question, there are some promising signs but I haven't succeeded in finding if there's been much progress since by searching.

So has anyone finished this job, or got very far with it?

Note: CLR 4.0 is now released. Time for another look-see.

A: 

Based on the response, I'm going to answer my question:

No.

Though of course if someone comes up with a better answer (or I come across one) I will update.

Daniel Earwicker