This project is currently under development, stay tuned :)
Use Autopsy to read the syntax of compiled delegates.
Uses ILSpy to decompile delegates by reading their IL.
IDelegateReader reader = DelegateReader.CreateCachedWithDefaultAssemblyProvider();
SyntaxTree GetSyntaxTree(MyFunc func)
{
return reader.Read(func);
}
var tree = GetSyntaxTree(x =>
{
if (x >= 0 && x < 5) return 1;
else if (x >= 5 && x < 10) return 2;
return 3;
});
Console.WriteLine(tree.ToString());
Prints
internal int <Main>b__2_0 (int x)
{
if (x >= 0 && x < 5) {
return 1;
}
if (x >= 5 && x < 10) {
return 2;
}
return 3;
}
See Demo Project
Coming soon