File tree Expand file tree Collapse file tree
StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44namespace StyleCop . Analyzers . ReadabilityRules
55{
66 using System . Collections . Immutable ;
7+ using System . Linq ;
78 using Microsoft . CodeAnalysis ;
89 using Microsoft . CodeAnalysis . CSharp ;
910 using Microsoft . CodeAnalysis . CSharp . Syntax ;
@@ -45,10 +46,22 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte
4546 private static void HandleDeclaration ( SyntaxNodeAnalysisContext context )
4647 {
4748 var fieldDeclaration = ( BaseFieldDeclarationSyntax ) context . Node ;
48- if ( fieldDeclaration . Declaration . Variables . Count > 1 )
49+ var variables = fieldDeclaration . Declaration . Variables ;
50+
51+ if ( variables . Count < 2 || fieldDeclaration . SemicolonToken . IsMissing )
4952 {
50- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , fieldDeclaration . GetLocation ( ) ) ) ;
53+ return ;
5154 }
55+
56+ foreach ( VariableDeclaratorSyntax variable in variables )
57+ {
58+ if ( variable . IsMissing )
59+ {
60+ return ;
61+ }
62+ }
63+
64+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , fieldDeclaration . GetLocation ( ) ) ) ;
5265 }
5366 }
5467}
You can’t perform that action at this time.
0 commit comments