SA1202 Ordering by visibility


SA1202 violation is raised when protected members come before internal members, and the documentation for SA1202 agrees with this ordering.

I believe this to be a bug, though, because protected is visible outside the declaring assembly by default (for non-sealed types), while internal is not. Protected is documented by Sandcastle for use by inheritors, while internal is usually not.

In order of decreasing visibility, the order should be public, protected, protected-internal, internal, private.

Is there an easy way to enforce that order without completely disabling this rule? I would still like to check for correct member ordering, but in order of decreasing visibility.
Closed Aug 1, 2013 at 4:39 PM by andyr


andyr wrote Nov 13, 2012 at 1:28 PM

See http://stylecop.codeplex.com/discussions/355722 for detail. Access modifiers are checked to be in the order: Public = 0, Internal = 1, ProtectedInternal = 2, Protected = 3, Private = 4, ProtectedAndInternal = 5