@@ -127,10 +127,7 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con
127
127
128
128
if ( ! string . IsNullOrEmpty ( textWithoutTrailingWhitespace ) )
129
129
{
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 ) )
134
131
{
135
132
int spanStart = textToken . SpanStart + textWithoutTrailingWhitespace . Length ;
136
133
ImmutableDictionary < string , string > properties = null ;
@@ -164,10 +161,15 @@ void SetReplaceChar()
164
161
}
165
162
else if ( xmlElement . Content [ i ] . IsInlineElement ( ) && ! currentParagraphDone )
166
163
{
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
+ }
171
173
}
172
174
else if ( xmlElement . Content [ i ] is XmlElementSyntax childXmlElement )
173
175
{
@@ -200,5 +202,13 @@ void SetReplaceChar()
200
202
}
201
203
}
202
204
}
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
+ }
203
213
}
204
214
}
0 commit comments