Intellisense "Convert to method" feature on local functions with optional parameters does not update call sites properly #76562
Description
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.
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.
Activity