Skip to content

BRO1130: Query clauses spanning multiple lines should begin on own line

A clause that spans several lines starts on its own line. Replaces StyleCop SA1105.

Example

Before

using System.Linq;

public class Orders
{
    public object InRange(int[] amounts) =>
        from a in amounts where a > 10 &&
            a < 100
        select a;
}

After

using System.Linq;

public class Orders
{
    public object InRange(int[] amounts) =>
        from a in amounts
        where a > 10 &&
            a < 100
        select a;
}

Why

A multi-line clause that starts at the end of another line hides where it begins.

How the fix works

The clause moves to its own line, indented like BRO1128 indents clauses.

Not reported

  • A clause after a comment on the same line (the fix would have to move the comment).

Compared with StyleCop

Same positions and output.