Skip to content

BRO1140: A record with an empty body should end with ';'

A record with a parameter list and nothing in its body ends with ;: record Point(int X, int Y);. Not a StyleCop rule (Roslynator RCS1251, Meziantou MA0206).

Example

Before

public record Point(int X, int Y)
{
}

public record struct Size(int Width, int Height) { }

After

public record Point(int X, int Y);

public record struct Size(int Width, int Height);

Why

The empty braces suggest a body that isn't there. The positional record's short form says the same in one line.

How the fix works

The text from the end of the declaration's header (parameters, base type or constraints) to the } becomes ;. A ; after the } (which BRO1101 would remove) is part of the replaced text, and an empty body that BRO1509 expands first is replaced the same way, so the rules converge in any order.

Not reported

  • A record without a parameter list (record R { }).
  • A comment or directive inside or around the braces.

Compared with StyleCop

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