@@ -346,33 +346,53 @@ private static void HandleMemberList(SyntaxNodeAnalysisContext context, SyntaxLi
346346 if ( ! members [ i - 1 ] . ContainsDiagnostics && ! members [ i ] . ContainsDiagnostics )
347347 {
348348 // Report if
349- // the current declaration is not a field declaration
349+ // the current declaration is not a field declaration or property declaration
350350 // or the previous declaration is of different type
351351 // or the previous declaration spans across multiple lines
352352 //
353- // Note that the order of checking is important, as the call to IsMultiLine requires a FieldDeclarationSyntax,
354- // something that can only be guaranteed if the first two checks fail.
355- if ( ! members [ i ] . IsKind ( SyntaxKind . FieldDeclaration )
356- || ! members [ i - 1 ] . IsKind ( members [ i ] . Kind ( ) )
357- || IsMultiline ( ( FieldDeclarationSyntax ) members [ i - 1 ] ) )
353+ // Note that the order of checking is important, as the call to IsMultiLine requires a
354+ // FieldDeclarationSyntax or PropertyDeclarationSyntax, something that can only be guaranteed if the
355+ // first two checks fail.
356+ if ( members [ i ] . IsKind ( SyntaxKind . FieldDeclaration )
357+ && members [ i - 1 ] . IsKind ( members [ i ] . Kind ( ) )
358+ && ! IsMultiline ( ( FieldDeclarationSyntax ) members [ i - 1 ] ) )
358359 {
359- ReportIfThereIsNoBlankLine ( context , members [ i - 1 ] , members [ i ] ) ;
360+ continue ;
361+ }
362+
363+ if ( members [ i ] . IsKind ( SyntaxKind . PropertyDeclaration )
364+ && members [ i - 1 ] . IsKind ( members [ i ] . Kind ( ) )
365+ && ! IsMultiline ( ( PropertyDeclarationSyntax ) members [ i ] )
366+ && ! IsMultiline ( ( PropertyDeclarationSyntax ) members [ i - 1 ] ) )
367+ {
368+ continue ;
360369 }
370+
371+ ReportIfThereIsNoBlankLine ( context , members [ i - 1 ] , members [ i ] ) ;
361372 }
362373 }
363374 }
364375
365376 private static bool IsMultiline ( FieldDeclarationSyntax fieldDeclaration )
366377 {
367- var lineSpan = fieldDeclaration . GetLineSpan ( ) ;
368- var attributeLists = fieldDeclaration . AttributeLists ;
378+ return IsMultiline ( fieldDeclaration , fieldDeclaration . AttributeLists ) ;
379+ }
380+
381+ private static bool IsMultiline ( PropertyDeclarationSyntax propertyDeclaration )
382+ {
383+ return IsMultiline ( propertyDeclaration , propertyDeclaration . AttributeLists ) ;
384+ }
385+
386+ private static bool IsMultiline ( MemberDeclarationSyntax memberDeclaration , SyntaxList < AttributeListSyntax > attributeLists )
387+ {
388+ var lineSpan = memberDeclaration . GetLineSpan ( ) ;
369389
370390 int startLine ;
371391
372392 // Exclude attributes when determining if a field declaration spans multiple lines
373393 if ( attributeLists . Count > 0 )
374394 {
375- var lastAttributeSpan = fieldDeclaration . SyntaxTree . GetLineSpan ( attributeLists . Last ( ) . FullSpan ) ;
395+ var lastAttributeSpan = memberDeclaration . SyntaxTree . GetLineSpan ( attributeLists . Last ( ) . FullSpan ) ;
376396 startLine = lastAttributeSpan . EndLinePosition . Line ;
377397 }
378398 else
0 commit comments