@@ -123,6 +123,7 @@ internal class SA1201ElementsMustAppearInTheCorrectOrder : DiagnosticAnalyzer
123123
124124 // extern alias and usings are missing here because the compiler itself is enforcing the right order.
125125 private static readonly ImmutableArray < SyntaxKind > OuterOrder = ImmutableArray . Create (
126+ SyntaxKindEx . FileScopedNamespaceDeclaration ,
126127 SyntaxKind . NamespaceDeclaration ,
127128 SyntaxKind . DelegateDeclaration ,
128129 SyntaxKind . EnumDeclaration ,
@@ -149,6 +150,7 @@ internal class SA1201ElementsMustAppearInTheCorrectOrder : DiagnosticAnalyzer
149150 private static readonly Dictionary < SyntaxKind , string > MemberNames = new Dictionary < SyntaxKind , string >
150151 {
151152 [ SyntaxKind . NamespaceDeclaration ] = "namespace" ,
153+ [ SyntaxKindEx . FileScopedNamespaceDeclaration ] = "namespace" ,
152154 [ SyntaxKind . DelegateDeclaration ] = "delegate" ,
153155 [ SyntaxKind . EnumDeclaration ] = "enum" ,
154156 [ SyntaxKind . InterfaceDeclaration ] = "interface" ,
@@ -172,7 +174,7 @@ internal class SA1201ElementsMustAppearInTheCorrectOrder : DiagnosticAnalyzer
172174 } ;
173175
174176 private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > CompilationUnitAction = HandleCompilationUnit ;
175- private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > NamespaceDeclarationAction = HandleNamespaceDeclaration ;
177+ private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration ;
176178 private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > TypeDeclarationAction = HandleTypeDeclaration ;
177179
178180 /// <inheritdoc/>
@@ -186,7 +188,7 @@ public override void Initialize(AnalysisContext context)
186188 context . EnableConcurrentExecution ( ) ;
187189
188190 context . RegisterSyntaxNodeAction ( CompilationUnitAction , SyntaxKind . CompilationUnit ) ;
189- context . RegisterSyntaxNodeAction ( NamespaceDeclarationAction , SyntaxKind . NamespaceDeclaration ) ;
191+ context . RegisterSyntaxNodeAction ( BaseNamespaceDeclarationAction , SyntaxKinds . BaseNamespaceDeclaration ) ;
190192 context . RegisterSyntaxNodeAction ( TypeDeclarationAction , SyntaxKinds . TypeDeclaration ) ;
191193 }
192194
@@ -218,7 +220,7 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty
218220 HandleMemberList ( context , elementOrder , kindIndex , compilationUnit . Members , OuterOrder ) ;
219221 }
220222
221- private static void HandleNamespaceDeclaration ( SyntaxNodeAnalysisContext context , StyleCopSettings settings )
223+ private static void HandleBaseNamespaceDeclaration ( SyntaxNodeAnalysisContext context , StyleCopSettings settings )
222224 {
223225 var elementOrder = settings . OrderingRules . ElementOrder ;
224226 int kindIndex = elementOrder . IndexOf ( OrderingTrait . Kind ) ;
@@ -227,9 +229,9 @@ private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context
227229 return ;
228230 }
229231
230- var compilationUnit = ( NamespaceDeclarationSyntax ) context . Node ;
232+ var baseNamespaceDeclaration = ( BaseNamespaceDeclarationSyntaxWrapper ) context . Node ;
231233
232- HandleMemberList ( context , elementOrder , kindIndex , compilationUnit . Members , OuterOrder ) ;
234+ HandleMemberList ( context , elementOrder , kindIndex , baseNamespaceDeclaration . Members , OuterOrder ) ;
233235 }
234236
235237 private static void HandleMemberList ( SyntaxNodeAnalysisContext context , ImmutableArray < OrderingTrait > elementOrder , int kindIndex , SyntaxList < MemberDeclarationSyntax > members , ImmutableArray < SyntaxKind > order )
0 commit comments