@@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.DocumentationRules
77 using System . Collections . Immutable ;
88 using System . IO ;
99 using System . Linq ;
10- using System . Threading ;
1110 using Microsoft . CodeAnalysis ;
1211 using Microsoft . CodeAnalysis . CSharp ;
1312 using Microsoft . CodeAnalysis . CSharp . Syntax ;
@@ -42,6 +41,7 @@ internal class SA1649FileNameMustMatchTypeName : DiagnosticAnalyzer
4241 new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormat , AnalyzerCategory . DocumentationRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , Description , HelpLink ) ;
4342
4443 private static readonly Action < CompilationStartAnalysisContext > CompilationStartAction = HandleCompilationStart ;
44+ private static readonly Action < SyntaxTreeAnalysisContext , StyleCopSettings > SyntaxTreeAction = Analyzer . HandleSyntaxTree ;
4545
4646 /// <inheritdoc/>
4747 public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; } =
@@ -55,21 +55,12 @@ public override void Initialize(AnalysisContext context)
5555
5656 private static void HandleCompilationStart ( CompilationStartAnalysisContext context )
5757 {
58- var analyzer = new Analyzer ( context . Options , context . CancellationToken ) ;
59- context . RegisterSyntaxTreeActionHonorExclusions ( analyzer . HandleSyntaxTreeAction ) ;
58+ context . RegisterSyntaxTreeActionHonorExclusions ( SyntaxTreeAction ) ;
6059 }
6160
62- private class Analyzer
61+ private static class Analyzer
6362 {
64- private readonly FileNamingConvention fileNamingConvention ;
65-
66- public Analyzer ( AnalyzerOptions options , CancellationToken cancellationToken )
67- {
68- StyleCopSettings settings = options . GetStyleCopSettings ( cancellationToken ) ;
69- this . fileNamingConvention = settings . DocumentationRules . FileNamingConvention ;
70- }
71-
72- public void HandleSyntaxTreeAction ( SyntaxTreeAnalysisContext context )
63+ public static void HandleSyntaxTree ( SyntaxTreeAnalysisContext context , StyleCopSettings settings )
7364 {
7465 var syntaxRoot = context . Tree . GetRoot ( context . CancellationToken ) ;
7566
@@ -86,7 +77,7 @@ public void HandleSyntaxTreeAction(SyntaxTreeAnalysisContext context)
8677
8778 var fileName = Path . GetFileName ( context . Tree . FilePath ) ;
8879 string expectedFileName ;
89- switch ( this . fileNamingConvention )
80+ switch ( settings . DocumentationRules . FileNamingConvention )
9081 {
9182 case FileNamingConvention . Metadata :
9283 expectedFileName = GetMetadataFileName ( firstTypeDeclaration ) ;
@@ -99,7 +90,7 @@ public void HandleSyntaxTreeAction(SyntaxTreeAnalysisContext context)
9990
10091 if ( string . Compare ( fileName , expectedFileName , StringComparison . OrdinalIgnoreCase ) != 0 )
10192 {
102- if ( this . fileNamingConvention == FileNamingConvention . StyleCop
93+ if ( settings . DocumentationRules . FileNamingConvention == FileNamingConvention . StyleCop
10394 && string . Compare ( fileName , GetSimpleFileName ( firstTypeDeclaration ) , StringComparison . OrdinalIgnoreCase ) == 0 )
10495 {
10596 return ;
0 commit comments