@@ -19,12 +19,14 @@ public class VisibilityOrder : ClassNodeChecker {
1919
2020 public override void Check ( SyntaxNodeAnalysisContext context ) {
2121 for ( var i = MemberType . Delegate ; i <= MemberType . NestedType ; i ++ ) {
22- CheckType ( context , i , true ) ;
23- CheckType ( context , i , false ) ;
22+ CheckType ( context , i , true , true ) ;
23+ CheckType ( context , i , false , true ) ;
24+ CheckType ( context , i , true , false ) ;
25+ CheckType ( context , i , false , false ) ;
2426 }
2527 }
2628
27- private void CheckType ( SyntaxNodeAnalysisContext context , MemberType memberType , bool isStatic ) {
29+ private void CheckType ( SyntaxNodeAnalysisContext context , MemberType memberType , bool isStatic , bool isReadOnly ) {
2830 var type = VisibilityType . Public ;
2931 var current = type . Kinds ( ) ;
3032 SyntaxKind [ ] previous = [ ] ;
@@ -34,10 +36,19 @@ private void CheckType(SyntaxNodeAnalysisContext context, MemberType memberType,
3436
3537 bool IsKind ( SyntaxKind kind )
3638 => tokens . Any ( it => it . IsKind ( kind ) ) ;
39+
40+ var isConstKeyword = IsKind ( SyntaxKind . ConstKeyword ) ;
41+ var isStaticKeyword = IsKind ( SyntaxKind . StaticKeyword ) ;
42+ var isReadOnlyKeyword = IsKind ( SyntaxKind . ReadOnlyKeyword ) ;
3743
38- if ( isStatic && ! IsKind ( SyntaxKind . StaticKeyword ) && ! IsKind ( SyntaxKind . ConstKeyword ) )
44+ if ( isStatic && ! isStaticKeyword && ! isConstKeyword )
3945 continue ;
40- else if ( ! isStatic && ( IsKind ( SyntaxKind . StaticKeyword ) || IsKind ( SyntaxKind . ConstKeyword ) ) )
46+ else if ( ! isStatic && ( isStaticKeyword || isConstKeyword ) )
47+ continue ;
48+
49+ if ( isReadOnly && ! isReadOnlyKeyword && ! isConstKeyword )
50+ continue ;
51+ else if ( ! isReadOnly && ( isReadOnlyKeyword || isConstKeyword ) )
4152 continue ;
4253
4354 if ( current . Any ( IsKind ) ) {
0 commit comments