Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.01 KB

README.md

File metadata and controls

50 lines (37 loc) · 1.01 KB

Autopsy

This project is currently under development, stay tuned :)

Nuget

Use Autopsy to read the syntax of compiled delegates.

Autopsy.ILSpy

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

Autopsy.Roslyn

Coming soon