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

Refactor: Extract Local Function #32135

Closed vsfeedback closed 4 years ago

vsfeedback commented 5 years ago

Given

public void Add()
{
    var radius = 1.23;

    var area = 3.14 * radius * radius
}

When

"Quick Actions and Refactorings" menu is opened and "Extract Local Function" is selected

Then

public void Add()
{
    var radius = 1.23;
    NewLocalFunction();

    void NewLocalFunction()
    {
        var area = 3.14 * radius * radius;
    }
}
_This issue has been moved from https://developercommunity.visualstudio.com/content/idea/360438/refactor-extract-local-function.html VSTS ticketId: 707648_ _These are the original issue comments:_ Fiona Niu[MSFT] on 10/17/2018, 07:11 PM (77 days ago):

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about a week on our next steps.

Kendra Havens [MSFT] on 10/31/2018, 00:53 PM (64 days ago):

Your suggestion has been queued up for prioritization. Feature suggestions are prioritized based on the value to our broader developer community and the product roadmap. We may not be able to pursue this one immediately, but we will continue to monitor it up to 90 days for community input

Kendra Havens [MSFT] on 1/3/2019, 00:35 PM (58 min ago):

To clarify, is this request specifically for providing an option for the extracted method to be local as opposed to the current extract method refactoring? Would you prefer both options to appear in the Quick Actions drop down all the time or only in a specific context? I appreciate any details that help explain your preferred experience.

Lopez Marc Rainier on 1/3/2019, 00:51 PM (42 min ago):

The request is specifically for providing an additional option for the extracted method to be local in addition to the current extract method refactoring. Both options appearing in the Quick Actions if the code to extract is inside a regular method and not already in a local function is my preferred experience.

333fred commented 5 years ago

@jinujoseph do we have any plans to enable this in the near future? I find myself wishing for this every few days.

jinujoseph commented 5 years ago

@333fred , hopefully soon image