Skip to content

Commit 065af6a

Browse files
authored
Merge pull request #2708 from vweijsters/fix-2699
Fixed issue where SA1002 was reported when a semicolon is the last ch…
2 parents 1d073d7 + 62bb9ac commit 065af6a

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1002UnitTests.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,8 @@ Comment Line 2 */
326326
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
327327
}
328328

329-
/// <summary>
330-
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#1426.
331-
/// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1426
332-
/// </summary>
333-
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
334329
[Fact]
330+
[WorkItem(1426, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1426")]
335331
public async Task TestPrecededByBlockCommentAsync()
336332
{
337333
string testCode = @"
@@ -360,12 +356,8 @@ void MethodName()
360356
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
361357
}
362358

363-
/// <summary>
364-
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#403.
365-
/// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/403
366-
/// </summary>
367-
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
368359
[Fact]
360+
[WorkItem(403, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/403")]
369361
public async Task TestSemicolonAtBeginningOfLineAsync()
370362
{
371363
string testCode = @"
@@ -412,6 +404,15 @@ int x
412404
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
413405
}
414406

407+
[Fact]
408+
[WorkItem(2699, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2699")]
409+
public async Task TestSemiColonAtEndOfFileAsync()
410+
{
411+
string testCode = @"using System;";
412+
413+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
414+
}
415+
415416
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
416417
{
417418
yield return new SA1002SemicolonsMustBeSpacedCorrectly();

StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1002SemicolonsMustBeSpacedCorrectly.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ private static void HandleSemicolonToken(SyntaxTreeAnalysisContext context, Synt
107107

108108
break;
109109

110+
case SyntaxKind.None:
111+
// The semi colon is the last character in the file.
112+
return;
113+
110114
default:
111115
break;
112116
}

0 commit comments

Comments
 (0)