Is there a library that can decompile a method into an expression tree with CLR 4.0 support?

Previous questions asked if delegates could be compiled into expression trees, for example:

  • Convert .net Func <T> to .net Expression expression <Func β†’>

There were sensible answers at that time:

  • It is possible, but very difficult and there is no standard library solution.
  • Use a reflector!

But, fortunately, there are some very crazy / crazy great people who love reverse engineering and they make difficult things easy for all of us.

Clearly, you can decompile IL in C #, as Reflector does, and so you could instead orient CLR 4.0 expression trees with support for all types of statements. This is interesting because it doesn’t matter if the built-in special compiler support for Expression<> lambdas never expands to support expression expression trees in the compiler. A library solution can fill a gap. Then we would have a high-level starting point for writing aspect-like code manipulations without having to mess with raw ILs.

As noted in the answers to the above related question, there are some promising signs , but I have not been able to find if there has been much progress after the search.

So, did anyone finish this job or get it very far?

Note. CLR 4.0 is now released. Time for a different look - look.

+6
c # expression-trees
source share
2 answers

Based on the answer, I am going to answer my question:

Not.

Although, of course, if someone comes up with a better answer (or I came across it), I will update.

0
source share

I made a library that supports .NET 3.5 expression trees:
https://github.com/ashmind/expressive

I tried to make an internal API, so .NET 4.0 support would not be so complicated. You can add or modify steps in the implementation of IPipeline to achieve just that.

One thing I did not do, and it will be difficult, is loop support.

+3
source share

All Articles