@@ -78,41 +78,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool
7878 {
7979 foreach ( var xmlElement in syntaxList . OfType < XmlElementSyntax > ( ) )
8080 {
81- if ( xmlElement . StartTag ? . Name ? . LocalName . ValueText == XmlCommentHelper . SeeAlsoXmlTag )
82- {
83- continue ;
84- }
85-
86- var elementDone = false ;
87- for ( var i = xmlElement . Content . Count - 1 ; ! elementDone && ( i >= 0 ) ; i -- )
88- {
89- if ( xmlElement . Content [ i ] is XmlTextSyntax contentNode )
90- {
91- for ( var j = contentNode . TextTokens . Count - 1 ; ! elementDone && ( j >= 0 ) ; j -- )
92- {
93- var textToken = contentNode . TextTokens [ j ] ;
94- var textWithoutTrailingWhitespace = textToken . Text . TrimEnd ( ' ' , '\r ' , '\n ' ) ;
95-
96- if ( ! string . IsNullOrEmpty ( textWithoutTrailingWhitespace ) )
97- {
98- if ( ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal ) )
99- {
100- var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( textToken . SpanStart + textWithoutTrailingWhitespace . Length , 1 ) ) ;
101- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
102- }
103-
104- elementDone = true ;
105- }
106- }
107- }
108- else if ( xmlElement . Content [ i ] . IsInlineElement ( ) )
109- {
110- // Treat empty XML elements as a "word not ending with a period"
111- var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( xmlElement . Content [ i ] . Span . End , 1 ) ) ;
112- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
113- elementDone = true ;
114- }
115- }
81+ HandleSectionXmlElement ( context , xmlElement ) ;
11682 }
11783 }
11884
@@ -134,5 +100,44 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co
134100 }
135101 }
136102 }
103+
104+ private static void HandleSectionXmlElement ( SyntaxNodeAnalysisContext context , XmlElementSyntax xmlElement )
105+ {
106+ if ( xmlElement . StartTag ? . Name ? . LocalName . ValueText == XmlCommentHelper . SeeAlsoXmlTag )
107+ {
108+ return ;
109+ }
110+
111+ var elementDone = false ;
112+ for ( var i = xmlElement . Content . Count - 1 ; ! elementDone && ( i >= 0 ) ; i -- )
113+ {
114+ if ( xmlElement . Content [ i ] is XmlTextSyntax contentNode )
115+ {
116+ for ( var j = contentNode . TextTokens . Count - 1 ; ! elementDone && ( j >= 0 ) ; j -- )
117+ {
118+ var textToken = contentNode . TextTokens [ j ] ;
119+ var textWithoutTrailingWhitespace = textToken . Text . TrimEnd ( ' ' , '\r ' , '\n ' ) ;
120+
121+ if ( ! string . IsNullOrEmpty ( textWithoutTrailingWhitespace ) )
122+ {
123+ if ( ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal ) )
124+ {
125+ var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( textToken . SpanStart + textWithoutTrailingWhitespace . Length , 1 ) ) ;
126+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
127+ }
128+
129+ elementDone = true ;
130+ }
131+ }
132+ }
133+ else if ( xmlElement . Content [ i ] . IsInlineElement ( ) )
134+ {
135+ // Treat empty XML elements as a "word not ending with a period"
136+ var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( xmlElement . Content [ i ] . Span . End , 1 ) ) ;
137+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
138+ elementDone = true ;
139+ }
140+ }
141+ }
137142 }
138143}
0 commit comments