From 768691729204442eb237c82359878b5d7ecd4ee6 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Sat, 25 May 2024 21:53:32 +0200 Subject: [PATCH 1/3] update --- .../BlankLineBetweenDeclarationsAnalyzer.cs | 16 +++++++++------- ...kLineBetweenSingleLineDeclarationsTests.cs | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs b/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs index 843480381e..f96260cdde 100644 --- a/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs @@ -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) diff --git a/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs b/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs index 8ab9b750e7..6ccb2c117c 100644 --- a/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs +++ b/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs @@ -135,6 +135,25 @@ enum E /// B = 1 } +"); + } + + [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddBlankLineBetweenSingleLineDeclarations)] + public async Task TestNoDiagnostic_EnumMemberDeclaration_DocumentationComment() + { + await VerifyNoDiagnosticAsync(@" +public enum C +{ + /// + /// a + /// + A = 0, + + /// + /// b + /// + B = 1 +} "); } } From 77815e53f24041e30f4547424409fe8f84f09ec0 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Sat, 25 May 2024 21:56:07 +0200 Subject: [PATCH 2/3] update --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 5f8c85679d..83be89e9a2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 From 1837a8728e53fd41079294d85091c706426d0879 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Sat, 25 May 2024 21:58:31 +0200 Subject: [PATCH 3/3] update --- .../RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs b/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs index 6ccb2c117c..25afbe75da 100644 --- a/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs +++ b/src/Tests/Formatting.Analyzers.Tests/RCS0012AddBlankLineBetweenSingleLineDeclarationsTests.cs @@ -139,7 +139,7 @@ enum E } [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddBlankLineBetweenSingleLineDeclarations)] - public async Task TestNoDiagnostic_EnumMemberDeclaration_DocumentationComment() + public async Task TestNoDiagnostic_EnumMemberDeclarations_DocumentationComment() { await VerifyNoDiagnosticAsync(@" public enum C