Roslyn: .editorconfig should have setting to not indent case blocks

Created on 17 Mar 2019  路  3Comments  路  Source: dotnet/roslyn

Version Used: 15.9.9

Steps to Reproduce:

Format this switch statement:

```C#
switch (value)
{
case CaseLabel1:
return 42;

case CaseLabel2:
{
    var x = ComputeValue();
    return x;
}

}


**Expected Behavior**:

Have the option in `.editorconfig` to indent case contents, but not case blocks.

**Actual Behavior**:

I can either not indent case contents, in which case it will look like this:

```C#
switch (value)
{
    case CaseLabel1:
    return 42;

    case CaseLabel2:
    {
        var x = ComputeValue();
        return x;
    }
}

or I can choose to indent case contents in which case it will also indent blocks:

```C#
switch (value)
{
case CaseLabel1:
return 42;

case CaseLabel2:
    {
        var x = ComputeValue();
        return x;
    }

}
```

Area-IDE Question Resolution-Answered

Most helpful comment

You want to set:

csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false

All 3 comments

There is already a setting for this. I can look up the name tomorrow when I'm at a computer.

You want to set:

csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false

Looks like the problem was missing documentation for me.

Was this page helpful?
0 / 5 - 0 ratings