Skip to content

BRO1522: Place '=' consistently when an assignment wraps

When the line breaks next to the = of an assignment (also compound ones like += and ??=) or an initializer (fields, properties, locals, parameter defaults, enum members), the = goes at the end of the broken line (the default) or at the beginning of the continuation line. Not a StyleCop rule.

Example

Before

public class Shipping
{
    private readonly decimal baseRate
        = 4.95m;

    public decimal Cost(decimal weight)
    {
        var cost
            = baseRate;
        cost
            += weight * 0.5m;
        return cost;
    }
}

After

public class Shipping
{
    private readonly decimal baseRate =
        4.95m;

    public decimal Cost(decimal weight)
    {
        var cost =
            baseRate;
        cost +=
            weight * 0.5m;
        return cost;
    }
}

Why

One place for the = in the whole codebase. The end of the line is what C# code does almost everywhere: in the reference repositories StyleBro is tested on (2026-10-04), 518 of the 524 assignments and initializers that break next to = have it at the end of the line (all eight repositories agree).

How the fix works

Only the = moves: it goes to the other side of the line break with one space between it and the code on its line. The line break and the continuation line's indentation stay as they are.

Configuration

[*.cs]
# end_of_line (default) or beginning_of_line.
stylebro_equals_placement_when_wrapping = end_of_line

Not reported

  • A { or [ after the = (an array initializer or collection expression on its own lines): int[] a = + { 1, 2 } is brace layout, not wrapping.
  • A query after the = (var q = + from x in ...): the query layout rules (BRO1127-BRO1130) indent its clauses by whether from starts its line, so they would re-indent the query.
  • Named arguments and members ([Attr(Name = ..., new { X = ...), using aliases.
  • A comment or a directive next to the =, an = alone on its line, and code with syntax errors.

Compared with StyleCop

StyleCop has no such rule. Roslynator's RCS0052 does the same, off by default and with its own option (roslynator_equals_token_new_line). stylebro-migrate turns this rule off, so migrating doesn't change a StyleCop-clean repository.