@@ -354,6 +354,56 @@ public SomeException()
354354 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
355355 }
356356
357+ /// <summary>
358+ /// Verifies that an empty comment at the start of a source file will be handled correctly.
359+ /// This is a regression test for #1708
360+ /// </summary>
361+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
362+ [ Fact ]
363+ public async Task VerifyThatEmptyCommentAtFileStartWillBeHandledProperlyAsync ( )
364+ {
365+ var testCode = @"//
366+ public class TestClass
367+ {
368+ }
369+ " ;
370+
371+ var fixedTestCode = @"public class TestClass
372+ {
373+ }
374+ " ;
375+
376+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 1 , 1 ) ;
377+
378+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
379+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
380+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
381+ }
382+
383+ /// <summary>
384+ /// Verifies that an empty comment at the end of a source file will be handled correctly.
385+ /// </summary>
386+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
387+ [ Fact ]
388+ public async Task VerifyThatEmptyCommentAtFileEndWillBeHandledProperlyAsync ( )
389+ {
390+ var testCode = @"public class TestClass
391+ {
392+ }
393+ //" ;
394+
395+ var fixedTestCode = @"public class TestClass
396+ {
397+ }
398+ " ;
399+
400+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 4 , 1 ) ;
401+
402+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
403+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
404+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
405+ }
406+
357407 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
358408 {
359409 yield return new SA1120CommentsMustContainText ( ) ;
0 commit comments