Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndentSwitchCaseSection handled improperly if case only contains a block #1351

Closed
meitinger opened this issue Nov 30, 2018 · 1 comment · Fixed by #1353
Closed

IndentSwitchCaseSection handled improperly if case only contains a block #1351

meitinger opened this issue Nov 30, 2018 · 1 comment · Fixed by #1353
Labels

Comments

@meitinger
Copy link

How to reproduce:

Add/set the following in omnisharp.json:

{
    "FormattingOptions": {
        "IndentSwitchCaseSection": false
    }
}

Format the following C# code:

class Test
{
    public int Foo(int bar)
    {
        switch (bar)
        {
            case 1:
                return 1;
            case 2:
                {
                    return 2;
                }
            case 3:
                ;
                {
                    return 3;
                }
        }
    }
}

Expected result:

class Test
{
    public int Foo(int bar)
    {
        switch (bar)
        {
            case 1:
            return 1;
            case 2:
            {
                return 2;
            }
            case 3:
            ;
            {
                return 3;
            }
        }
    }
}

Actual result:

class Test
{
    public int Foo(int bar)
    {
        switch (bar)
        {
            case 1:
            return 1;
            case 2:
                {
                    return 2;
                }
            case 3:
            ;
            {
                return 3;
            }
        }
    }
}
@DustinCampbell
Copy link
Contributor

The issue here is that there are two IndentSwitchCaseSection settings support by the C# formatter in Roslyn, but OmniSharp only exposes one of them. The other option is IndentSwitchCaseSectionWhenBlock, which OmniSharp needs to support.

filipw added a commit to filipw/omnisharp-roslyn that referenced this issue Dec 5, 2018
filipw added a commit to filipw/omnisharp-roslyn that referenced this issue Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants