Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMethodException after changing method signature on hot reload #87032

Closed
isadorasophia opened this issue Jun 1, 2023 · 7 comments
Closed

Comments

@isadorasophia
Copy link

Description

When trying to rename methods with hot reload on .NET 7, I consistently get a MissingMethodException when changing the methods signatures.

Reproduction Steps

  1. Debug the following app with .NET 7:
static void Main(string[] args)
{
    Debugger.Break();
    Foo(23);
}

static int Foo(int something)
{
    Console.WriteLine(something);
    return 0;
}
  1. F5 and break.
  2. Modify Foo with:
static int Foo(int something, bool aValue = false)
{
    Console.WriteLine(something);
    return 0;
}
  1. Successfully apply changes and F5

Expected behavior

Successfully execute the modified Foo method.

Actual behavior

MissingMethodException gets thrown:

image

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jun 1, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 1, 2023
@isadorasophia
Copy link
Author

Similar to #65442 (on Roslyn)

@mikelle-rogers
Copy link
Member

I tried reproducing this with .NET 7 in Visual Studio, without checking "Do not use top-level statements". In order to get the Debugger.Break to stop the process, I had to remove the main function. After changing Foo, and continuing, the following popup resulted:
image

@mikelle-rogers
Copy link
Member

I then tried reproducing this with .NET 7 in Visual Studio and checked the box next to "Do not use top-level statements" and the issue reproduced.

@AaronRobinsonMSFT AaronRobinsonMSFT added area-Diagnostics-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners untriaged New issue has not been triaged by the area owner labels Jun 2, 2023
@ghost
Copy link

ghost commented Jun 2, 2023

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When trying to rename methods with hot reload on .NET 7, I consistently get a MissingMethodException when changing the methods signatures.

Reproduction Steps

  1. Debug the following app with .NET 7:
static void Main(string[] args)
{
    Debugger.Break();
    Foo(23);
}

static int Foo(int something)
{
    Console.WriteLine(something);
    return 0;
}
  1. F5 and break.
  2. Modify Foo with:
static int Foo(int something, bool aValue = false)
{
    Console.WriteLine(something);
    return 0;
}
  1. Successfully apply changes and F5

Expected behavior

Successfully execute the modified Foo method.

Actual behavior

MissingMethodException gets thrown:

image

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: isadorasophia
Assignees: -
Labels:

area-Diagnostics-coreclr, untriaged

Milestone: -

@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 8.0.0 milestone Jun 2, 2023
@AaronRobinsonMSFT
Copy link
Member

@isadorasophia I've not debugged this, but this might be an issue with the default value in the signature. What if you update both the callsite and the method?

@tmat Are default values supported in EnC in general?

@tmat
Copy link
Member

tmat commented Jun 2, 2023

/cc @davidwengier

The reason for MethodMissingException is that Main is not recompiled because it does not have any changes, so it calls the old version of Foo, which now throws because it has been "deleted".

This behavior is currently expected. Issue dotnet/roslyn#59264 tracks improving this by emitting a call to the newer version of Foo into the body of its old version instead of MethodMissingException throw.

@tmat
Copy link
Member

tmat commented Jun 2, 2023

Closing this issue as dup of dotnet/roslyn#65442.

@tmat tmat closed this as completed Jun 2, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants