dotnet/roslyn

Block syntax in expression-bodied method is not reformatted when refactoring implicitly converts it to block-bodied method

開放

#71,636 建立於 2024年1月14日

 (3 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-IDEBughelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Version Used: VS 17.8.4

Steps to Reproduce:

For both methods, open the lightbulb menu on the parameter s and select "Add null check" (or any other refactoring that implicitly converts it to a block body).

class C
{
    int M(int v, string s) => v switch
    {
        _ => 0
    };

    object M(string s) => new
    {
        Id = 1
    };
}

Expected Behavior: The block syntax is reformatted and has the correct indentation, just like it is when selecting the "Use block body for method" refactoring. image

Actual Behavior: The block syntax is not reformatted and has the old and wrong indentation as a result. image

貢獻者指南