Is there a library that can decompile a method into an Expression tree, with support for CLR 4.0?
Posted
by Daniel Earwicker
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Earwicker
Published on 2010-02-21T13:23:15Z
Indexed on
2010/04/15
21:13 UTC
Read the original article
Hit count: 356
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.
© Stack Overflow or respective owner