@@ -127,10 +127,7 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con
127127
128128 if ( ! string . IsNullOrEmpty ( textWithoutTrailingWhitespace ) )
129129 {
130- if ( ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal )
131- && ! textWithoutTrailingWhitespace . EndsWith ( ".)" , StringComparison . Ordinal )
132- && ( startingWithFinalParagraph || ! textWithoutTrailingWhitespace . EndsWith ( ":" , StringComparison . Ordinal ) )
133- && ! textWithoutTrailingWhitespace . EndsWith ( "-or-" , StringComparison . Ordinal ) )
130+ if ( IsMissingRequiredPeriod ( textWithoutTrailingWhitespace , startingWithFinalParagraph ) )
134131 {
135132 int spanStart = textToken . SpanStart + textWithoutTrailingWhitespace . Length ;
136133 ImmutableDictionary < string , string > properties = null ;
@@ -164,10 +161,15 @@ void SetReplaceChar()
164161 }
165162 else if ( xmlElement . Content [ i ] . IsInlineElement ( ) && ! currentParagraphDone )
166163 {
167- // Treat empty XML elements as a "word not ending with a period"
168- var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( xmlElement . Content [ i ] . Span . End , 1 ) ) ;
169- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
170- currentParagraphDone = true ;
164+ var lastTextElement = XmlCommentHelper . TryGetLastTextElementWithContent ( xmlElement . Content [ i ] ) ;
165+
166+ if ( lastTextElement is null // Treat empty XML elements as a "word not ending with a period"
167+ || IsMissingRequiredPeriod ( lastTextElement . TextTokens . Last ( ) . Text . TrimEnd ( ' ' , '\r ' , '\n ' ) , startingWithFinalParagraph ) )
168+ {
169+ var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( xmlElement . Content [ i ] . Span . End , 1 ) ) ;
170+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
171+ currentParagraphDone = true ;
172+ }
171173 }
172174 else if ( xmlElement . Content [ i ] is XmlElementSyntax childXmlElement )
173175 {
@@ -200,5 +202,13 @@ void SetReplaceChar()
200202 }
201203 }
202204 }
205+
206+ private static bool IsMissingRequiredPeriod ( string textWithoutTrailingWhitespace , bool startingWithFinalParagraph )
207+ {
208+ return ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal )
209+ && ! textWithoutTrailingWhitespace . EndsWith ( ".)" , StringComparison . Ordinal )
210+ && ( startingWithFinalParagraph || ! textWithoutTrailingWhitespace . EndsWith ( ":" , StringComparison . Ordinal ) )
211+ && ! textWithoutTrailingWhitespace . EndsWith ( "-or-" , StringComparison . Ordinal ) ;
212+ }
203213 }
204214}
0 commit comments