@@ -111,7 +111,7 @@ public static void HandleVariableDeclaration(SyntaxNodeAnalysisContext context,
111111 return ;
112112 }
113113
114- var fieldDeclaration = syntax . Parent . IsKind ( SyntaxKind . FieldDeclaration ) ;
114+ var declarationType = syntax . Parent . IsKind ( SyntaxKind . FieldDeclaration ) ? "field" : "variable" ;
115115 foreach ( var variableDeclarator in syntax . Variables )
116116 {
117117 if ( variableDeclarator == null )
@@ -120,7 +120,7 @@ public static void HandleVariableDeclaration(SyntaxNodeAnalysisContext context,
120120 }
121121
122122 var identifier = variableDeclarator . Identifier ;
123- CheckIdentifier ( context , identifier , settings , fieldDeclaration ) ;
123+ CheckIdentifier ( context , identifier , settings , declarationType ) ;
124124 }
125125 }
126126
@@ -159,7 +159,7 @@ public static void HandleForEachStatement(SyntaxNodeAnalysisContext context, Sty
159159 CheckIdentifier ( context , ( ( ForEachStatementSyntax ) context . Node ) . Identifier , settings ) ;
160160 }
161161
162- private static void CheckIdentifier ( SyntaxNodeAnalysisContext context , SyntaxToken identifier , StyleCopSettings settings , bool fieldDeclaration = false )
162+ private static void CheckIdentifier ( SyntaxNodeAnalysisContext context , SyntaxToken identifier , StyleCopSettings settings , string declarationType = "variable" )
163163 {
164164 if ( identifier . IsMissing )
165165 {
@@ -190,7 +190,7 @@ private static void CheckIdentifier(SyntaxNodeAnalysisContext context, SyntaxTok
190190 }
191191
192192 // Variable names must begin with lower-case letter
193- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , identifier . GetLocation ( ) , fieldDeclaration ? "field" : "variable" , name ) ) ;
193+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , identifier . GetLocation ( ) , declarationType , name ) ) ;
194194 }
195195 }
196196 }
0 commit comments