SA1214.md
November 26, 2025 ยท View on GitHub
SA1214
| TypeName | SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements |
| CheckId | SA1214 |
| Category | Ordering Rules |
Cause
A readonly field is positioned beneath a non-readonly field.
Rule description
A violation of this rule occurs when a readonly field is positioned beneath a non-readonly field.
This rule applies only to field declarations. The C# 8 readonly members feature (e.g. readonly struct methods, properties, indexers, or accessors) is not covered by SA1214; those members follow the normal ordering rules for their declaration kind.
How to fix violations
To fix an instance of this violation, place all readonly fields above all non-readonly fields.
How to suppress violations
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1214:ReadonlyElementsMustAppearBeforeNonReadonlyElements", Justification = "Reviewed.")]
#pragma warning disable SA1214 // ReadonlyElementsMustAppearBeforeNonReadonlyElements
#pragma warning restore SA1214 // ReadonlyElementsMustAppearBeforeNonReadonlyElements