@@ -52,6 +52,8 @@ internal class SA1629DocumentationTextMustEndWithAPeriod : ElementDocumentationB
5252 /// </summary>
5353 internal const string NoCodeFixKey = "NoCodeFix" ;
5454
55+ internal const string ReplaceCharKey = "CharToReplace" ;
56+
5557 private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1629.md" ;
5658 private static readonly LocalizableString Title = new LocalizableResourceString ( nameof ( DocumentationResources . SA1629Title ) , DocumentationResources . ResourceManager , typeof ( DocumentationResources ) ) ;
5759 private static readonly LocalizableString MessageFormat = new LocalizableResourceString ( nameof ( DocumentationResources . SA1629MessageFormat ) , DocumentationResources . ResourceManager , typeof ( DocumentationResources ) ) ;
@@ -128,8 +130,30 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con
128130 && ( startingWithFinalParagraph || ! textWithoutTrailingWhitespace . EndsWith ( ":" , StringComparison . Ordinal ) )
129131 && ! textWithoutTrailingWhitespace . EndsWith ( "-or-" , StringComparison . Ordinal ) )
130132 {
131- var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( textToken . SpanStart + textWithoutTrailingWhitespace . Length , 1 ) ) ;
132- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location ) ) ;
133+ int spanStart = textToken . SpanStart + textWithoutTrailingWhitespace . Length ;
134+ ImmutableDictionary < string , string > properties = null ;
135+ if ( textWithoutTrailingWhitespace . EndsWith ( "," , StringComparison . Ordinal )
136+ || textWithoutTrailingWhitespace . EndsWith ( ";" , StringComparison . Ordinal ) )
137+ {
138+ spanStart -= 1 ;
139+ SetReplaceChar ( ) ;
140+ }
141+ else if ( textWithoutTrailingWhitespace . EndsWith ( ",)" , StringComparison . Ordinal )
142+ || textWithoutTrailingWhitespace . EndsWith ( ";)" , StringComparison . Ordinal ) )
143+ {
144+ spanStart -= 2 ;
145+ SetReplaceChar ( ) ;
146+ }
147+
148+ var location = Location . Create ( xmlElement . SyntaxTree , new TextSpan ( spanStart , 1 ) ) ;
149+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , location , properties ) ) ;
150+
151+ void SetReplaceChar ( )
152+ {
153+ var propertiesBuilder = ImmutableDictionary . CreateBuilder < string , string > ( ) ;
154+ propertiesBuilder . Add ( ReplaceCharKey , string . Empty ) ;
155+ properties = propertiesBuilder . ToImmutable ( ) ;
156+ }
133157 }
134158
135159 currentParagraphDone = true ;
0 commit comments