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¶
Like StyleCop's default ("newlineAtEndOfFile": "allow"), a file may end with one line break or without one. To
require a final line break, use the SDK's own setting, which dotnet format applies:
[*.cs]
insert_final_newline = true
Compared with StyleCop¶
Same results as StyleCop's default setting. StyleCop's require and omit settings correspond to
insert_final_newline = true and false in .editorconfig.