BRO1517: Code should not contain multiple blank lines in a row¶
Two or more blank lines in a row become one. Replaces StyleCop SA1507.
Example¶
Before¶
public class Report
{
public int Total(int a, int b)
{
var sum = a + b;
return sum;
}
}
After¶
public class Report
{
public int Total(int a, int b)
{
var sum = a + b;
return sum;
}
}
Why¶
One blank line separates; more add scrolling without saying anything more.
How the fix works¶
The first blank line stays, the others are removed, in every run of blank lines at once (also several runs between
directives, like empty #regions in a row). Blank lines inside strings and in disabled #if code aren't touched.
This rule replaces the SDK's IDE2000, which writes merge conflict markers in multi-targeted projects under
dotnet format and also counts blank lines at the start of a file and before } (see decisions).