SA1400.md
November 26, 2025 ยท View on GitHub
SA1400
| TypeName | SA1400AccessModifierMustBeDeclared |
| CheckId | SA1400 |
| Category | Maintainability Rules |
Cause
The access modifier for a C# element has not been explicitly defined.
Rule description
C# allows elements to be defined without an access modifier. Depending upon the type of element, C# will automatically assign an access level to the element in this case.
This rule requires an access modifier to be explicitly defined for every element. This removes the need for the reader to make assumptions about the code, improving the readability of the code.
Members declared in an interface are implicitly public and do not need an explicit access modifier. This includes default interface members introduced in C# 8 (instance members with default implementations, static interface members, and nested interface members such as delegates). SA1400 does not report diagnostics for these interface members.
How to fix violations
To fix a violation of this rule, add an access modifier to the declaration of the element.
How to suppress violations
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1400:AccessModifierMustBeDeclared", Justification = "Reviewed.")]
#pragma warning disable SA1400 // AccessModifierMustBeDeclared
#pragma warning restore SA1400 // AccessModifierMustBeDeclared