dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.06k stars 4.04k forks source link

Extra calls in Asm #75842

Closed 1zaboy closed 2 days ago

1zaboy commented 3 days ago

Version Used: .net 8

Steps to Reproduce:

I have method

    public static void RecordError(Exception exception)
    {
    }

And I have code witch call RecordError

                try
                {
                     ...
                }
                catch (Exception ex)
                {
                    O.RecordError(ex);
                }

But when I build it and check Asm, I see call [Test.O:RecordError(System.Exception)] in asm

Since the method does not contain any code, its call could be removed.

I use .net 8 and Disasmo for see asm

Expected Behavior: not call method

Actual Behavior: call method

vladd commented 3 days ago

Are you compiling Debug or Release?

CyrusNajmabadi commented 2 days ago

Roslyn does not produce asm. We produce IL. The runtime converts that IL to asm using the AOT or Jit compilers. So this is a question for dotnet/runtime.

1zaboy commented 2 days ago

@vladd Release