Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 1.41 KB

DeclareRecordClassExplicitly.md

File metadata and controls

42 lines (27 loc) · 1.41 KB

Prefer explicit reference type records

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,)

Summary

Adds the optional class keyword to reference record declarations to add clarity for readers.

Remarks

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.

Example

Before:

public record Record(int Number, string Text);

After:

public record class Record(int Number, string Text);

See also

History