dotnet/roslyn

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

オープン

#71,636 opened on 2024/01/14

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-IDEBughelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

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

コントリビューターガイド