Skip to content

Commit

Permalink
Fix RCS1055 (#1361)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Jan 14, 2024
1 parent 2057d5d commit b350632
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix analyzer [RCS1055](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1055) ([PR](https://github.com/dotnet/roslynator/pull/1361))

## [4.9.0] - 2024-01-10

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ private static void AnalyzeEnumDeclaration(SyntaxNodeAnalysisContext context)
{
var declaration = (EnumDeclarationSyntax)context.Node;

SyntaxToken semicolon = declaration.SemicolonToken;

if (semicolon.Parent is not null
&& !semicolon.IsMissing)
if (declaration.CloseBraceToken.IsKind(SyntaxKind.CloseBraceToken))
{
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.UnnecessarySemicolonAtEndOfDeclaration, semicolon);
SyntaxToken semicolon = declaration.SemicolonToken;

if (semicolon.Parent is not null
&& !semicolon.IsMissing)
{
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.UnnecessarySemicolonAtEndOfDeclaration, semicolon);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public async Task TestNoDiagnostic_Interface()
{
await VerifyNoDiagnosticAsync(@"
interface C;
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UnnecessarySemicolonAtEndOfDeclaration)]
public async Task TestNoDiagnostic_Enum()
{
await VerifyNoDiagnosticAsync(@"
enum E;
");
}
}

0 comments on commit b350632

Please sign in to comment.