Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RCS1055 #1361

Merged
merged 2 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
");
}
}