EgorBo / Disasmo

VS2022 Add-in. Click on any method or class to see what .NET Core's JIT generates for them (ASM).
MIT License
638 stars 39 forks source link

Methods in generic classes cannot be disassembled, even i run mode #58

Open poizan42 opened 3 months ago

poizan42 commented 3 months ago

Example:

using System.Runtime.CompilerServices;

namespace FooBar;

internal class Foo<TBar>
{
    public Foo(TBar bar)
    {
        Bar = bar;
    }
    public TBar? Bar { get; }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public void Frob()
    {
        Console.WriteLine(Bar);
    }
}

internal class Program
{
    static void Main(string[] args)
    {
        Foo<int> foo = new(42);
        foo.Frob();
    }
}

Choosing "Disasm this" on Foo.Frob() results in an empty output, even when Run mode is selected.

Looking at the log makes it pretty obvious why

Executing a command in directory "C:\projects\test\DisasmoTest":
    dotnet build -f net8.0 -c Release -o bin\Release\net8.0\Disasmo-v5.9.2 --no-self-contained /p:RuntimeIdentifier="" /p:RuntimeIdentifiers="" /p:WarningLevel=0 /p:DefineConstants=DISASMO /p:TreatWarningsAsErrors=false "C:\projects\test\DisasmoTest\DisasmoTest.csproj"
Env.vars:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
DOTNET_CLI_TELEMETRY_OPTOUT=1

Executing a command in directory "C:\projects\test\DisasmoTest\bin\Release\net8.0\Disasmo-v5.9.2":
    dotnet "DisasmoTest.dll"
Env.vars:
DOTNET_JitDisasm=*Foo:Frob
DOTNET_TieredPGO=0
DOTNET_JitDisasmDiffable=0
DOTNET_TieredCompilation=0
DOTNET_ReadyToRun=1
DOTNET_TieredPGO_InstrumentOnlyHotCode=0
DOTNET_TC_CallCountingDelayMs=0

*Foo:Frob obviously does not match FooBar.Foo`1[int]:Frob().

It should probably be at least *Foo`1[*:Frob