File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
StyleCop.Analyzers.Test/DocumentationRules
StyleCop.Analyzers/DocumentationRules Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -451,6 +451,52 @@ public interface ITest
451451 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
452452 }
453453
454+ [ Theory ]
455+ [ WorkItem ( 2744 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2744" ) ]
456+ [ InlineData ( "Summary. (For example.)" ) ]
457+ [ InlineData ( "Summary (for example)." ) ]
458+ public async Task TestSentenceEndingWithParenthesesAsync ( string allowedSummary )
459+ {
460+ var testCode = $@ "
461+ /// <summary>
462+ /// { allowedSummary }
463+ /// </summary>
464+ public interface ITest
465+ {{
466+ }}
467+ " ;
468+
469+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
470+ }
471+
472+ [ Fact ]
473+ [ WorkItem ( 2744 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2744" ) ]
474+ public async Task TestSentenceEndingWithParenthesesWithoutPeriodAsync ( )
475+ {
476+ var testCode = @"
477+ /// <summary>
478+ /// Summary (for example)
479+ /// </summary>
480+ public interface ITest
481+ {
482+ }
483+ " ;
484+ var fixedTestCode = $@ "
485+ /// <summary>
486+ /// Summary (for example).
487+ /// </summary>
488+ public interface ITest
489+ {{
490+ }}
491+ " ;
492+
493+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 3 , 26 ) ;
494+
495+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
496+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
497+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
498+ }
499+
454500 [ Fact ]
455501 public async Task TestMultipleParagraphBlocksAsync ( )
456502 {
Original file line number Diff line number Diff line change @@ -91,7 +91,8 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co
9191 var textWithoutTrailingWhitespace = node . Value . TrimEnd ( ' ' , '\r ' , '\n ' ) ;
9292 if ( ! string . IsNullOrEmpty ( textWithoutTrailingWhitespace ) )
9393 {
94- if ( ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal ) )
94+ if ( ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal )
95+ && ! textWithoutTrailingWhitespace . EndsWith ( ".)" , StringComparison . Ordinal ) )
9596 {
9697 context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , diagnosticLocations [ 0 ] , NoCodeFixProperties ) ) ;
9798
@@ -123,6 +124,7 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con
123124 if ( ! string . IsNullOrEmpty ( textWithoutTrailingWhitespace ) )
124125 {
125126 if ( ! textWithoutTrailingWhitespace . EndsWith ( "." , StringComparison . Ordinal )
127+ && ! textWithoutTrailingWhitespace . EndsWith ( ".)" , StringComparison . Ordinal )
126128 && ( startingWithFinalParagraph || ! textWithoutTrailingWhitespace . EndsWith ( ":" , StringComparison . Ordinal ) )
127129 && ! textWithoutTrailingWhitespace . EndsWith ( "-or-" , StringComparison . Ordinal ) )
128130 {
You can’t perform that action at this time.
0 commit comments