CodeFixProvider: DeclareRecordClassExplicitly.cs
Title | Explicitly add class keyword to reference record declaration |
Fixes | F02001 |
Language | C# 10.0 or greater |
Applies to | [0.9.0,) |
Adds the optional class
keyword to reference record declarations to add clarity for readers.
Both a record
and a record class
declare a reference type and are semantically equal.
The class
keyword is optional, distinguishing these types from record struct
and readonly record struct
declarations, both value types with the semantic difference of immutability.
Before:
public record Record(int Number, string Text);
After:
public record class Record(int Number, string Text);