Skip to content

BRO1410: Patterns should not use unnecessary parentheses

Parentheses around a pattern that means the same without them are removed: x is (> 0), o is (string s), case (int i):, a pair around another pair. Not a StyleCop rule: SA1119 (BRO1405) only looks at parenthesized expressions.

Example

Before

public static class Shapes
{
    public static bool IsPositive(int x) => x is (> 0);

    public static int Length(object o) => o is (string s) ? s.Length : 0;

    public static bool IsSmall(int x) => x is ((1 or 2)) or 3;
}

After

public static class Shapes
{
    public static bool IsPositive(int x) => x is > 0;

    public static int Length(object o) => o is string s ? s.Length : 0;

    public static bool IsSmall(int x) => x is 1 or 2 or 3;
}

Why

Like BRO1405 for expressions: parentheses that don't group anything make the reader look for a precedence question that isn't there.

How the fix works

The fix removes ( and ) and any spaces just inside them; where the tokens would run together (is(string s)), a space is left. Like BRO1405, the statement (or member) is parsed again without the parentheses, and they're only removed when the result is the same pattern.

In an IDE the parentheses are also faded: a hidden companion diagnostic, BRO1410_p, is reported on the ( and ) of every finding, with the Unnecessary tag (like StyleCop's SA1119_p for SA1119; BRO1405 has BRO1405_p). It can't be configured, has no fix of its own, and is only reported where BRO1410 is on.

Not reported

  • Parentheses that change the meaning: not (A or B), (A or B) and C, A or (B or C) (patterns group from the left, so A or B or C is a different tree).
  • The parentheses BRO1407 (SA1408) wants between and and or: A or (B and C), (A and B) or C. A second pair around them (A or ((B and C))) is reported. With BRO1407 off, or dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary, these are removed too.
  • A parenthesized constant (x is (null), x is (1)): C# parses it as a parenthesized expression, which is BRO1405's.
  • Parentheses with a comment and a line break inside them. A comment on one line with the pattern is kept: (> 1 /* low */) becomes > 1 /* low */.

Compared with StyleCop

StyleCop has no such rule. stylebro-migrate turns it off (see Rules beyond StyleCop).

In the 12 reference repositories (2026-10-09) there are 32 parenthesized patterns and none is reported: 24 put an and inside an or (c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z'), which BRO1407 asks for) and 8 follow not. With BRO1407 off, 12 of those 24 are reported (OpenTelemetry; the others are in #if code the survey didn't compile).