Skip to content

BRO1127: Query clause should follow previous clause

No blank line between the clauses of a query expression. Replaces StyleCop SA1102.

Example

Before

using System.Linq;

public class Orders
{
    public object Open(int[] ids) =>
        from id in ids

        where id > 0
        select id;
}

After

using System.Linq;

public class Orders
{
    public object Open(int[] ids) =>
        from id in ids
        where id > 0
        select id;
}

Why

A query is one expression; a blank line in the middle makes it look like two.

How the fix works

The blank lines are removed; the clause keeps its indentation.

Not reported

  • Blank lines with a comment line between them (removing only the blank ones wouldn't satisfy the rule, and the comment would have to move), and directives between the clauses (like StyleCop).

Compared with StyleCop

Same positions and output, except the commented case above, which StyleCop reports.