Skip to content

Commit

Permalink
Fix analyzer RCS0036 (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed May 10, 2024
1 parent bc61073 commit 9f123b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix analyzer [RCS1085](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1085) ([PR](https://github.com/dotnet/roslynator/pull/1461))
- Fix analyzer [RCS1077](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1077) ([PR](https://github.com/dotnet/roslynator/pull/1463))
- [CLI] Fix `roslynator analyze --include/--exclude` ([PR](https://github.com/dotnet/roslynator/pull/1459))
- Fix analyzer [RCS0036](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0036) ([PR](https://github.com/dotnet/roslynator/pull/1466))

## [4.12.2] - 2024-04-23

Expand Down
Expand Up @@ -118,8 +118,11 @@ private static void Analyze(SyntaxNodeAnalysisContext context, SyntaxList<Member
{
if (block.Kind == TriviaBlockKind.BlankLine)
{
if (MemberKindEquals(previousMember, member))
if (!block.ContainsDocumentationComment
&& MemberKindEquals(previousMember, member))
{
ReportDiagnostic(context, DiagnosticRules.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind, block);
}
}
else
{
Expand Down Expand Up @@ -201,7 +204,8 @@ 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.Kind == TriviaBlockKind.BlankLine)
if (!block.ContainsDocumentationComment
&& block.Kind == TriviaBlockKind.BlankLine)
{
ReportDiagnostic(context, DiagnosticRules.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind, block);
}
Expand Down
Expand Up @@ -97,6 +97,36 @@ class C
string F = null;
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind)]
public async Task TestNoDiagnostic_DocCommentBetweenMembers()
{
await VerifyNoDiagnosticAsync(@"
class C
{
string P1 { get; set; }
/// <summary>
/// </summary>
string P2 { get; set; }
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind)]
public async Task TestNoDiagnostic_DocCommentBetweenEnumMembers()
{
await VerifyNoDiagnosticAsync(@"
enum C
{
A,
/// <summary>
/// </summary>
B,
}
");
}
}

0 comments on commit 9f123b6

Please sign in to comment.