SA1311.md
November 26, 2025 ยท View on GitHub
SA1311
| TypeName | SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter |
| CheckId | SA1311 |
| Category | Naming Rules |
Cause
The name of a static readonly field does not begin with an upper-case letter.
Rule description
A violation of this rule occurs when the name of a static readonly field begins with a lower-case letter.
C# 8 added readonly members for structs; this rule still only targets static readonly fields and ignores readonly methods, properties, indexers, or events. Accessible static readonly fields can also trigger SA1307, while SA1304 does not report static readonly fields. This prevents all three naming rules from firing on the same field while keeping static readonly fields covered.
How to fix violations
To fix a violation of this rule, change the name of the field so that it begins with an upper-case letter.
How to suppress violations
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1311:StaticReadonlyFieldsMustBeginWithUpperCaseLetter", Justification = "Reviewed.")]
#pragma warning disable SA1311 // StaticReadonlyFieldsMustBeginWithUpperCaseLetter
#pragma warning restore SA1311 // StaticReadonlyFieldsMustBeginWithUpperCaseLetter