Skip to content

BRO1503: Opening braces should not be followed by a blank line

The first line inside a block directly follows its opening brace. Replaces StyleCop SA1505.

Example

Before

public class Parser
{

    public int Parse(string text)
    {

        return int.Parse(text);
    }
}

After

public class Parser
{
    public int Parse(string text)
    {
        return int.Parse(text);
    }
}

Why

A blank line right after { adds height without separating anything; the brace already marks where the block starts. This is the counterpart of BRO1501, which removes blank lines before the brace.

How the fix works

The fix removes the blank lines directly below the brace, for every kind of opening brace: namespaces, types, members, statements and initializers.

Not reported

  • A brace followed by a comment on the same line ({ // note).
  • Braces inside strings, such as a { in a raw string literal. Only whitespace outside code is checked, never string contents.

Compared with StyleCop

Same results as StyleCop.