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.08k stars 4.04k forks source link

MissingMethodException when calling method prior to hot reload change #65442

Open isadorasophia opened 2 years ago

isadorasophia commented 2 years ago

Version Used: VS 17.4 with .NET 6/7 Steps to Reproduce:

  1. Debug the following app with F5
    
    static void Bar()
    {
    return;
    }

static void Main() { Debugger.Break();

Bar(); 

}

2. Enter break state and modify Bar()
```csharp
static void Bar(int foo = 0)
{
    return;
}
  1. Continue

Expected We successfully hot reload and call Bar().

Actual When calling bar, we see an exception being thrown.

System.MissingMethodException: 'Attempted to access a missing method.'

Fix Consider adding a better error message once this message occurs so the user can understand what actually happened. The hot reload issue itself is already being addressed.

tmat commented 2 years ago

@davidwengier

davidwengier commented 2 years ago

There is a possibility we can be smart enough to trampoline the call for this one. Otherwise, better exception message content suggestions welcome :)

tmat commented 2 years ago

Something like "Method has been deleted or its signature changed by Edit and Continue. Update the caller to avoid this exception."?