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

"Extract method" with a generic local function creates invalid code #22597

Closed
Tragetaschen opened this issue Oct 9, 2017 · 2 comments · Fixed by #76724
Closed

"Extract method" with a generic local function creates invalid code #22597

Tragetaschen opened this issue Oct 9, 2017 · 2 comments · Fixed by #76724
Labels
Area-IDE Feature - Extract Method Feature - Local Functions Local Functions help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@Tragetaschen
Copy link

Tragetaschen commented Oct 9, 2017

Version Used: VS 15.3.5

Steps to Reproduce:

private void test()
{
    void foo<T> (T bar) => Console.WriteLine(bar);
    foo(3);
}

Run "Extract Method" on the entire contents of test

Expected Behavior:

private void test()
{
    NewMethod();
}

private static void NewMethod()
{
    void foo<T>(T bar) => Console.WriteLine(bar);
    foo(3);
}

Actual Behavior:

private void test()
{
    NewMethod<T>();
}

private static void NewMethod<T>()
{
    void foo<T>(T bar) => Console.WriteLine(bar);
    foo(3);
}

NewMethod gets a generic parameter that isn't available at the call site (error) and generates a warning for the T on foo within NewMethod due to having the same name as NewMethod's T.

@jcouv
Copy link
Member

jcouv commented Oct 10, 2017

FYI @agocke

@jinujoseph jinujoseph added this to the Unknown milestone Oct 21, 2017
@CyrusNajmabadi CyrusNajmabadi added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Oct 25, 2024
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Oct 25, 2024
@CyrusNajmabadi
Copy link
Member

We would take a targeted community fix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature - Extract Method Feature - Local Functions Local Functions help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Completed
5 participants