BRO1507: Files should not end with blank lines¶
A file ends with its last line of code, followed by at most one line break. Replaces StyleCop SA1518.
Example¶
Before¶
public class Order
{
public int Id { get; set; }
}
After¶
public class Order
{
public int Id { get; set; }
}
Why¶
Blank lines at the end of a file are invisible noise, and they show up as changes in diffs when an editor adds or trims them.
How the fix works¶
The fix removes everything after the last line's line break: extra blank lines, and lines containing only spaces.
Configuration¶
A file may end with one line break or without one ("newlineAtEndOfFile": "allow" in stylecop.json). To
require a final line break, use the SDK's own setting, which dotnet format applies:
[*.cs]
insert_final_newline = true
The require and omit values of newlineAtEndOfFile in stylecop.json correspond to insert_final_newline = true
and false.