josephwoodward / VSCodeILViewer

A Visual Studio Code C# IL (Intermediate Language) Viewer
MIT License
98 stars 17 forks source link

Prettify the IL #8

Open josephwoodward opened 7 years ago

josephwoodward commented 7 years ago

Really interested in knowing how TryRoslyn render their IL. What format is it?

.class private auto ansi '<Module>'
{
} // end of class <Module>

.class public auto ansi beforefieldinit C
    extends [mscorlib]System.Object
{
    // Methods
    .method public hidebysig 
        instance void M () cil managed 
    {
        // Method begins at RVA 0x2050
        // Code size 2 (0x2)
        .maxstack 8

        IL_0000: nop                  // Do nothing (No operation)
        IL_0001: ret                  // Return from method, possibly with a value
    } // end of method C::M

    .method public hidebysig specialname rtspecialname 
        instance void .ctor () cil managed 
    {
        // Method begins at RVA 0x2053
        // Code size 8 (0x8)
        .maxstack 8

        IL_0000: ldarg.0              // Load argument 0 onto the stack
        IL_0001: call instance void [mscorlib]System.Object::.ctor() // Call method indicated on the stack with arguments
        IL_0006: nop                  // Do nothing (No operation)
        IL_0007: ret                  // Return from method, possibly with a value
    } // end of method C::.ctor

} // end of class C
pawlos commented 7 years ago

It looks like this is some kind of standard way of formatting as it can be seen in ILSpy, dnSpy but also ildasm produces the same output. It is also used in Wikipedia entries.

I can see that in case of ILSpy or dnSpy the ICSharpCode.Decompiler library (part of ILSpy - https://github.com/icsharpcode/ILSpy/tree/master/ICSharpCode.Decompiler) is used to produce such output. I'll try to check if it's possible to compile it to be used in this project.

josephwoodward commented 7 years ago

Oh good investigation! Would be interested to know if it supports .NET Standard.

pawlos commented 7 years ago

@JosephWoodward I'm not much into those .NET Standard stuff - is there a tool that could help checking if the code can be compiled for the given .NET standard?