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

Intellisense "Convert to method" feature on local functions with optional parameters does not update call sites properly #76562

Open
vsfeedback opened this issue Dec 24, 2024 · 0 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


The "Convert to method" feature in Intellisense on local functions does not update call sites properly when the local function has optional parameters that the call sites do not specify, if the local function references objects in the method they are contained in.

local function to method.gif

In the example above, it creates a new parameter for the referenced variable begin, and updates the call site to pass it in, but the original optional parameter is not specified in the updated code, which leaves it passing in the wrong argument.

It would probably be enough to just insert default for the optional parameters at the call sites in these cases.
Full problem example:

static void Main(string[] args)
{
    var begin = "Hello";
    Console.WriteLine(getFullString());

    string getFullString(bool exclamation = false)
    {
        var suffix = exclamation ? "!" : "";
        return begin + " World" + suffix;
    }
}

Original Comments

Feedback Bot on 20/12/2024, 10:06 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant