@@ -6,7 +6,6 @@ namespace StyleCop.Analyzers.NamingRules
66 using System ;
77 using System . Collections . Immutable ;
88 using System . Text . RegularExpressions ;
9- using System . Threading ;
109 using Helpers ;
1110 using Microsoft . CodeAnalysis ;
1211 using Microsoft . CodeAnalysis . CSharp ;
@@ -68,6 +67,7 @@ internal class SA1305FieldNamesMustNotUseHungarianNotation : DiagnosticAnalyzer
6867 private static readonly Regex HungarianRegex = new Regex ( @"^(?<notation>[a-z]{1,2})[A-Z]" ) ;
6968
7069 private static readonly Action < CompilationStartAnalysisContext > CompilationStartAction = HandleCompilationStart ;
70+ private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > VariableDeclarationAction = Analyzer . HandleVariableDeclaration ;
7171
7272 /// <inheritdoc/>
7373 public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; } =
@@ -81,21 +81,12 @@ public override void Initialize(AnalysisContext context)
8181
8282 private static void HandleCompilationStart ( CompilationStartAnalysisContext context )
8383 {
84- Analyzer analyzer = new Analyzer ( context . Options , context . CancellationToken ) ;
85- context . RegisterSyntaxNodeActionHonorExclusions ( analyzer . HandleVariableDeclarationSyntax , SyntaxKind . VariableDeclaration ) ;
84+ context . RegisterSyntaxNodeActionHonorExclusions ( VariableDeclarationAction , SyntaxKind . VariableDeclaration ) ;
8685 }
8786
88- private sealed class Analyzer
87+ private static class Analyzer
8988 {
90- private readonly NamingSettings namingSettings ;
91-
92- public Analyzer ( AnalyzerOptions options , CancellationToken cancellationToken )
93- {
94- StyleCopSettings settings = options . GetStyleCopSettings ( cancellationToken ) ;
95- this . namingSettings = settings . NamingRules ;
96- }
97-
98- public void HandleVariableDeclarationSyntax ( SyntaxNodeAnalysisContext context )
89+ public static void HandleVariableDeclaration ( SyntaxNodeAnalysisContext context , StyleCopSettings settings )
9990 {
10091 var syntax = ( VariableDeclarationSyntax ) context . Node ;
10192
@@ -136,12 +127,12 @@ public void HandleVariableDeclarationSyntax(SyntaxNodeAnalysisContext context)
136127 }
137128
138129 var notationValue = match . Groups [ "notation" ] . Value ;
139- if ( this . namingSettings . AllowCommonHungarianPrefixes && CommonPrefixes . Contains ( notationValue ) )
130+ if ( settings . NamingRules . AllowCommonHungarianPrefixes && CommonPrefixes . Contains ( notationValue ) )
140131 {
141132 continue ;
142133 }
143134
144- if ( this . namingSettings . AllowedHungarianPrefixes . Contains ( notationValue ) )
135+ if ( settings . NamingRules . AllowedHungarianPrefixes . Contains ( notationValue ) )
145136 {
146137 continue ;
147138 }
0 commit comments