@@ -5,14 +5,14 @@ namespace StyleCop.Analyzers.NamingRules
55{
66 using System ;
77 using System . Collections . Immutable ;
8- using System . Linq ;
98 using System . Text . RegularExpressions ;
10- using Helpers ;
119 using Microsoft . CodeAnalysis ;
1210 using Microsoft . CodeAnalysis . CSharp ;
1311 using Microsoft . CodeAnalysis . CSharp . Syntax ;
1412 using Microsoft . CodeAnalysis . Diagnostics ;
1513 using Settings . ObjectModel ;
14+ using StyleCop . Analyzers . Helpers ;
15+ using StyleCop . Analyzers . Lightup ;
1616
1717 /// <summary>
1818 /// The name of a field or variable in C# uses Hungarian notation.
@@ -76,6 +76,7 @@ internal class SA1305FieldNamesMustNotUseHungarianNotation : DiagnosticAnalyzer
7676 private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > JoinClauseAction = Analyzer . HandleJoinClause ;
7777 private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > JoinIntoClauseAction = Analyzer . HandleJoinIntoClause ;
7878 private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > ForEachStatementAction = Analyzer . HandleForEachStatement ;
79+ private static readonly Action < SyntaxNodeAnalysisContext , StyleCopSettings > SingleVariableDesignationAction = Analyzer . HandleSingleVariableDesignation ;
7980
8081 /// <inheritdoc/>
8182 public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; } =
@@ -96,6 +97,7 @@ public override void Initialize(AnalysisContext context)
9697 context . RegisterSyntaxNodeAction ( JoinClauseAction , SyntaxKind . JoinClause ) ;
9798 context . RegisterSyntaxNodeAction ( JoinIntoClauseAction , SyntaxKind . JoinIntoClause ) ;
9899 context . RegisterSyntaxNodeAction ( ForEachStatementAction , SyntaxKind . ForEachStatement ) ;
100+ context . RegisterSyntaxNodeAction ( SingleVariableDesignationAction , SyntaxKindEx . SingleVariableDesignation ) ;
99101 }
100102
101103 private static class Analyzer
@@ -189,6 +191,11 @@ public static void HandleForEachStatement(SyntaxNodeAnalysisContext context, Sty
189191 CheckIdentifier ( context , ( ( ForEachStatementSyntax ) context . Node ) . Identifier , settings ) ;
190192 }
191193
194+ public static void HandleSingleVariableDesignation ( SyntaxNodeAnalysisContext context , StyleCopSettings settings )
195+ {
196+ CheckIdentifier ( context , ( ( SingleVariableDesignationSyntaxWrapper ) context . Node ) . Identifier , settings ) ;
197+ }
198+
192199 private static void CheckIdentifier ( SyntaxNodeAnalysisContext context , SyntaxToken identifier , StyleCopSettings settings , string declarationType = "variable" )
193200 {
194201 if ( identifier . IsMissing )
0 commit comments