- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Extra newline in switch case statement with curly braces #1192
Labels
Milestone
Comments
This is what I ended up doing switch (someValue)
{
case 0:
{
// dedented because the only statement is a block
break;
}
case 1:
{
// indented because there are two statements, a block then a break
}
break;
} It looks a bit weird with the switch (someValue)
{
case 0:
{
// some comment
}
break;
case 1:
{
// some comment
}
break;
} And also with the block and switch (someValue)
{
case 0:
{
// some comment
}
break;
case 1:
{
// some comment
}
break;
} |
shocklateboy92
added a commit
that referenced
this issue
Mar 11, 2024
closes #1192 Co-authored-by: Lasath Fernando <devel@lasath.org>
This was referenced Apr 7, 2024
Closed
This was referenced Apr 26, 2024
1 task
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Input:
Output:
Expected behavior:
There shouldn't be an empty line added between the case statement and the opening curly brace.
For the record, I am not a fan of these curly braces, but you need to create a new scope if you want to declare the same variable name in multiple cases of the switch (CS0128). My coworkers always put the break outside the ending curly brace, which causes CSharpier to add a newline before the opening curly brace. There is a workaround by moving the break inside the closing curly brace, which I have been doing when I can. Doesn't change that the extra newline shouldn't be there in this case.
The text was updated successfully, but these errors were encountered: