BRO1146: Write 'record' without 'class'¶
A record is a class unless it says struct, so record class R is written record R. A record struct keeps its
keyword. Not a StyleCop rule: from Meziantou's
MA0174 (MA0175 is the opposite
style).
Example¶
Before¶
public record class 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¶
record alone has meant a reference type since C# 9; record class (C# 10) says the same with one more word. One form
for the same thing.
How the fix works¶
The class keyword and the whitespace before it are removed.
Not reported¶
- A comment between
recordandclass.
Compared with StyleCop¶
StyleCop has no such rule. stylebro-migrate turns it off (see
Rules beyond StyleCop).