SonarSource/sonar-dotnet

New Rule T0031: Move the property body on the same line.

pavel-mikula-sonarsource opened this issue · 0 comments

Coding style:

When using an arrow property or an arrow method, the => token must be on the same line as the declaration. Regarding the expression body:

  • for properties: it should be on the same line as the property declaration. It should be on the following line only when it is too long and would trigger S103.
private int name => "Lorem"; // Compliant
private int values[] =>  // Compliant
    [
    ];
public List<int> list => 
    new()  // Noncompliant
    {
    }
public List<int> list =>  new()  // Compliant
    {
    }

private int name => 
    "Ipsum"; // Noncompliant