Skip to content

Commit

Permalink
Fix analyzer RCS0012 (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed May 26, 2024
1 parent f92b3fc commit bf87ca2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix analyzer [RCS1108](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1108) ([PR](https://github.com/dotnet/roslynator/pull/1469))
- Fix analyzer [RCS1201](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1201) ([PR](https://github.com/dotnet/roslynator/pull/1470))
- Fix analyzer [RCS0012](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0012) ([PR](https://github.com/dotnet/roslynator/pull/1472))

## [4.12.3] - 2024-05-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,16 @@ private static void AnalyzeEnumDeclaration(SyntaxNodeAnalysisContext context)
if ((isSingleLine ?? (isSingleLine = tree.IsSingleLineSpan(member.Span, cancellationToken)).Value)
&& (isPreviousSingleLine ?? tree.IsSingleLineSpan(members[i - 1].Span, cancellationToken)))
{
if (!block.ContainsDocumentationComment
&& block.Kind == TriviaBlockKind.BlankLine)
if (!block.ContainsDocumentationComment)
{
ReportDiagnostic(context, DiagnosticRules.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind, block);
}
else
{
ReportDiagnostic(context, DiagnosticRules.AddBlankLineBetweenSingleLineDeclarations, block);
if (block.Kind == TriviaBlockKind.BlankLine)
{
ReportDiagnostic(context, DiagnosticRules.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind, block);
}
else
{
ReportDiagnostic(context, DiagnosticRules.AddBlankLineBetweenSingleLineDeclarations, block);
}
}
}
else if (block.Kind != TriviaBlockKind.BlankLine)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ enum E
/// </summary>
B = 1
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddBlankLineBetweenSingleLineDeclarations)]
public async Task TestNoDiagnostic_EnumMemberDeclarations_DocumentationComment()
{
await VerifyNoDiagnosticAsync(@"
public enum C
{
/// <summary>
/// a
/// </summary>
A = 0,
/// <summary>
/// b
/// </summary>
B = 1
}
");
}
}

0 comments on commit bf87ca2

Please sign in to comment.