@@ -6,6 +6,7 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules
66 using System . Collections . Generic ;
77 using System . Threading ;
88 using System . Threading . Tasks ;
9+ using Microsoft . CodeAnalysis ;
910 using Microsoft . CodeAnalysis . CodeFixes ;
1011 using Microsoft . CodeAnalysis . Diagnostics ;
1112 using StyleCop . Analyzers . ReadabilityRules ;
@@ -404,6 +405,41 @@ public async Task VerifyThatEmptyCommentAtFileEndWillBeHandledProperlyAsync()
404405 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
405406 }
406407
408+ /// <summary>
409+ /// Verifies that an unclosed multiline comment at the end of a source file will be handled correctly.
410+ /// This is a regression test for #2056
411+ /// </summary>
412+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
413+ [ Fact ]
414+ public async Task VerifyThatUnclosedCommentAtFileEndWillBeHandledProperlyAsync ( )
415+ {
416+ var testCode = @"public class TestClass
417+ {
418+ }
419+ /*" ;
420+
421+ var fixedTestCode = @"public class TestClass
422+ {
423+ }
424+ " ;
425+
426+ DiagnosticResult [ ] expected =
427+ {
428+ new DiagnosticResult
429+ {
430+ Id = "CS1035" ,
431+ Message = "End-of-file found, '*/' expected" ,
432+ Severity = DiagnosticSeverity . Error ,
433+ Locations = new [ ] { new DiagnosticResultLocation ( "Test0.cs" , 4 , 1 ) }
434+ } ,
435+ this . CSharpDiagnostic ( ) . WithLocation ( 4 , 1 ) ,
436+ } ;
437+
438+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
439+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
440+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
441+ }
442+
407443 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
408444 {
409445 yield return new SA1120CommentsMustContainText ( ) ;
0 commit comments