Stylecopanalyzers: Proposed rule: use trailing comma in multi-line switch expression

Created on 5 Nov 2019  路  1Comment  路  Source: DotNetAnalyzers/StyleCopAnalyzers

Like SA1413 where a trailing comma is required in multi-line initializes, I propose a rule where a trailing comma is required in a multi-line switch statement, for the same reason SA1413 was introduced:

string str = "hello";
string str2 = str switch
{
    "hello" => "hello",
    "goodbye" => "bye bye", // No warning.
};

string str3 = str switch
{
    "hello" => "hello",
    "goodbye" => "goodbye" // Warning: use trailing comma in multi-line switch statement.
};
bug c# 8 fixed

Most helpful comment

SA1413 itself should be updated to cover this case.

>All comments

SA1413 itself should be updated to cover this case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Onzi12 picture Onzi12  路  4Comments

patriksvensson picture patriksvensson  路  6Comments

Genarij picture Genarij  路  7Comments

wmjordan picture wmjordan  路  6Comments

SetTrend picture SetTrend  路  5Comments