Steeltoe
Steeltoe copied to clipboard
Address SA1401: Fields should be private
Address existing violations of SA1401: Fields should be private in the codebase and set severity to Warning in Steeltoe.Debug.ruleset and Steeltoe.Release.ruleset.
To find existing violations, enable the rule (see above) and rebuild src/Steeltoe.All.sln to make them appear in the Output window.
To address the violations, choose from the following on a case-by-case basis:
- Make the field private
- Convert the field into an auto-property (consider a get-only auto-property)
- Make the field
constorreadonly - ~Suppress the violation in code using
#pragma warning disable/restore, preceded by a justification comment if not obvious~
Note: less strict variants are S1104 and S2357, which solely warn on public fields. Whereas SA1401 applies to exposed fields (this includes protected, so it is more strict).