44namespace StyleCop . Analyzers . DocumentationRules
55{
66 using System ;
7+ using System . Collections . Generic ;
78 using System . Collections . Immutable ;
89 using System . Linq ;
910 using System . Xml . Linq ;
@@ -32,7 +33,7 @@ namespace StyleCop.Analyzers.DocumentationRules
3233 /// default documentation text generated by Visual Studio.</para>
3334 /// </remarks>
3435 [ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
35- internal class SA1608ElementDocumentationMustNotHaveDefaultSummary : ElementDocumentationSummaryBase
36+ internal class SA1608ElementDocumentationMustNotHaveDefaultSummary : ElementDocumentationBase
3637 {
3738 /// <summary>
3839 /// The ID for diagnostics produced by the <see cref="SA1608ElementDocumentationMustNotHaveDefaultSummary"/>
@@ -49,45 +50,51 @@ internal class SA1608ElementDocumentationMustNotHaveDefaultSummary : ElementDocu
4950 private static readonly DiagnosticDescriptor Descriptor =
5051 new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormat , AnalyzerCategory . DocumentationRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , Description , HelpLink ) ;
5152
52- private static readonly ImmutableArray < SyntaxKind > DocumentationCommentKinds =
53- ImmutableArray . Create ( SyntaxKind . SingleLineDocumentationCommentTrivia , SyntaxKind . MultiLineDocumentationCommentTrivia ) ;
53+ public SA1608ElementDocumentationMustNotHaveDefaultSummary ( )
54+ : base ( inheritDocSuppressesWarnings : true , matchElementName : XmlCommentHelper . SummaryXmlTag )
55+ {
56+ }
5457
5558 /// <inheritdoc/>
5659 public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; } =
5760 ImmutableArray . Create ( Descriptor ) ;
5861
5962 /// <inheritdoc/>
60- protected override void HandleXmlElement ( SyntaxNodeAnalysisContext context , DocumentationCommentTriviaSyntax documentation , XmlNodeSyntax syntax , XElement completeDocumentation , params Location [ ] diagnosticLocations )
61- {
62- if ( completeDocumentation != null )
63+ protected override void HandleXmlElement ( SyntaxNodeAnalysisContext context , IEnumerable < XmlNodeSyntax > syntaxList , params Location [ ] diagnosticLocations )
6364 {
64- // We are working with an <include> element
65- var includedSummaryElement = completeDocumentation . Nodes ( ) . OfType < XElement > ( ) . FirstOrDefault ( element => element . Name == XmlCommentHelper . SummaryXmlTag ) ;
66- if ( includedSummaryElement != null )
67- {
68- string text = includedSummaryElement . Value ;
65+ foreach ( var syntax in syntaxList )
66+ {
67+ var summaryElement = syntax as XmlElementSyntax ;
68+ var textElement = summaryElement ? . Content . FirstOrDefault ( ) as XmlTextSyntax ;
69+ if ( textElement != null )
70+ {
71+ string text = XmlCommentHelper . GetText ( textElement , true ) ;
6972
7073 if ( IsDefaultText ( text ) )
71- {
72- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , diagnosticLocations . First ( ) ) ) ;
74+ {
75+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , summaryElement . GetLocation ( ) ) ) ;
7376 return ;
7477 }
7578 }
7679 }
80+ }
7781
78- var summaryElement = syntax as XmlElementSyntax ;
79- var textElement = summaryElement ? . Content . FirstOrDefault ( ) as XmlTextSyntax ;
80- if ( textElement != null )
81- {
82- string text = XmlCommentHelper . GetText ( textElement , true ) ;
82+ /// <inheritdoc/>
83+ protected override void HandleCompleteDocumentation ( SyntaxNodeAnalysisContext context , XElement completeDocumentation , params Location [ ] diagnosticLocations )
84+ {
85+ // We are working with an <include> element
86+ var includedSummaryElement = completeDocumentation . Nodes ( ) . OfType < XElement > ( ) . FirstOrDefault ( element => element . Name == XmlCommentHelper . SummaryXmlTag ) ;
87+ if ( includedSummaryElement != null )
88+ {
89+ string text = includedSummaryElement . Value ;
8390
8491 if ( IsDefaultText ( text ) )
85- {
86- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , summaryElement . GetLocation ( ) ) ) ;
92+ {
93+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , diagnosticLocations . First ( ) ) ) ;
8794 return ;
88- }
89- }
90- }
95+ }
96+ }
97+ }
9198
9299 private static bool IsDefaultText ( string text )
93100 {
0 commit comments