Table of Contents

SA1203: Constants should appear before fields

Cause

A constant field is placed beneath a non-constant field.

Rule description

A violation of this rule occurs when a constant field is placed beneath a non-constant field. Constants should be placed above fields to indicate that the two are fundamentally different types of elements with different considerations for the compiler, different naming requirements, etc.

How to fix violations

To fix an instance of this violation, place all constants above all fields.

The code fix is not offered when reordering would move or cross a #region or #endregion directive. In this case, reorder the members manually while preserving paired region directives.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1203:ConstantsMustAppearBeforeFields", Justification = "Reviewed.")]
#pragma warning disable SA1203 // ConstantsMustAppearBeforeFields
#pragma warning restore SA1203 // ConstantsMustAppearBeforeFields