Skip to main content

RCS0061: Add/remove blank line between switch sections

Properties

PropertyValue
Default Severitydisabled by default
Minimum language version-

Examples

Example #1

.editorconfig
roslynator_blank_line_between_switch_sections = include
diagnostic.cs
switch (x)
{
case "foo":
return true;
case "bar":
return false;
default:
throw new InvalidOperationException();
}
fix.cs
switch (x)
{
case "foo":
return true;

case "bar":
return false;

default:
throw new InvalidOperationException();
}

Example #2

.editorconfig
roslynator_blank_line_between_switch_sections = omit
diagnostic.cs
switch (x)
{
case "foo":
return true;

case "bar":
return false;

default:
throw new InvalidOperationException();
}
fix.cs
switch (x)
{
case "foo":
return true;
case "bar":
return false;
default:
throw new InvalidOperationException();
}

Example #3

.editorconfig
roslynator_blank_line_between_switch_sections = omit_after_block
diagnostic.cs
switch (x)
{
case "foo":
{
return true;
}

case "bar":
{
return false;
}
}
fix.cs
switch (x)
{
case "foo":
{
return true;
}
case "bar":
{
return false;
}
}

Configuration

info

Option roslynator_blank_line_between_switch_sections is required to be set for this analyzer to work.

.editorconfig
# Include/omit blank line between switch sections
roslynator_blank_line_between_switch_sections = include|omit|omit_after_block

Applies to