Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.09 KB

SA1400.md

File metadata and controls

41 lines (30 loc) · 1.09 KB

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.

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