From 0b6e0c6c032ea678c6bd64e8fd3f7d485c640414 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Fri, 14 Aug 2026 18:26:42 +0200 Subject: [PATCH 1/3] fix(analyzers): report RCS0036 blank lines in records (#1812) RCS0036 already visited classes, structs, and record structs, but never registered RecordDeclaration, so equivalent properties in a record were ignored. Co-authored-by: Cursor --- ChangeLog.md | 1 + .../BlankLineBetweenDeclarationsAnalyzer.cs | 1 + ...enSingleLineDeclarationsOfSameKindTests.cs | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index b701c8073e..fec6e383ff 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fix analyzer [RCS0036](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0036) to report blank lines between single-line declarations in records ([#1812](https://github.com/dotnet/roslynator/issues/1812)) - Fix analyzer [RCS1046](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1046) to report `async void` methods without `Async` suffix ([PR](https://github.com/dotnet/roslynator/pull/1790)) - Fix analyzer [RCS1265](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1265) to not report catch clauses with a `when` filter ([PR](https://github.com/dotnet/roslynator/pull/1789)) - Fix analyzer [RCS0034](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0034) for types with a primary constructor and multiple constraint clauses ([PR](https://github.com/dotnet/roslynator/pull/1791)) diff --git a/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs b/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs index 01ec8cb4f4..74285f10a4 100644 --- a/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs @@ -42,6 +42,7 @@ public override void Initialize(AnalysisContext context) f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, + SyntaxKind.RecordDeclaration, #if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, #endif diff --git a/src/Tests/Formatting.Analyzers.Tests/RCS0036RemoveBlankLineBetweenSingleLineDeclarationsOfSameKindTests.cs b/src/Tests/Formatting.Analyzers.Tests/RCS0036RemoveBlankLineBetweenSingleLineDeclarationsOfSameKindTests.cs index 548586b5ca..7c692c0216 100644 --- a/src/Tests/Formatting.Analyzers.Tests/RCS0036RemoveBlankLineBetweenSingleLineDeclarationsOfSameKindTests.cs +++ b/src/Tests/Formatting.Analyzers.Tests/RCS0036RemoveBlankLineBetweenSingleLineDeclarationsOfSameKindTests.cs @@ -31,6 +31,25 @@ class C "); } + [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind)] + public async Task Test_Properties_Record() + { + await VerifyDiagnosticAndFixAsync(@" +record C +{ + string P1 { get; set; } +[| +|] string P2 { get; set; } +} +", @" +record C +{ + string P1 { get; set; } + string P2 { get; set; } +} +"); + } + [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind)] public async Task Test_Events() { From afea3cd49c42734e1896a0154ed856175035ccfb Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Fri, 14 Aug 2026 18:55:57 +0200 Subject: [PATCH 2/3] docs(skills): require Fixes #NNNN in analyzer bug-fix PRs A markdown issue link alone does not create a GitHub closing reference. Co-authored-by: Cursor --- .claude/skills/fix-analyzer-bug/SKILL.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.claude/skills/fix-analyzer-bug/SKILL.md b/.claude/skills/fix-analyzer-bug/SKILL.md index 209f77028d..1a0bdbd425 100644 --- a/.claude/skills/fix-analyzer-bug/SKILL.md +++ b/.claude/skills/fix-analyzer-bug/SKILL.md @@ -56,6 +56,28 @@ cd src && dotnet format Roslynator.sln --no-restore --verify-no-changes --severi Changelog examples: [references/changelog-examples.md](references/changelog-examples.md). +## Pull request + +When the fix targets a GitHub issue, the PR body **must** include a closing keyword on its own line (same pattern as recent analyzer fix PRs): + +```markdown +Fixes #NNNN +``` + +Use `Fixes #NNNN` or `Closes #NNNN`. A markdown link such as `[#1812](https://github.com/dotnet/roslynator/issues/1812)` does **not** create a GitHub issue reference and will not auto-close the issue. + +Place it after the Summary bullets and before the Test plan, for example: + +```markdown +## Summary +- … + +Fixes #1812 + +## Test plan +- … +``` + ## Common Mistakes | Mistake | Fix | @@ -68,3 +90,4 @@ Changelog examples: [references/changelog-examples.md](references/changelog-exam | Full test suite | Filter by rule id is enough | | Skip test | CONTRIBUTING.md requires tests for bug fixes | | `CHANGELOG.md` | `ChangeLog.md` at repo root | +| Markdown-only issue link in PR body | Use `Fixes #NNNN` so GitHub links and auto-closes the issue | From 2f3c293ddd4dbb490a8e87f09138593eccdf317a Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Fri, 14 Aug 2026 18:56:47 +0200 Subject: [PATCH 3/3] docs: point RCS0036 changelog entry at the PR Changelog entries use ([PR](...)) links; tighten the bug-fix skill examples to match. Co-authored-by: Cursor --- .claude/skills/fix-analyzer-bug/SKILL.md | 5 ++++- .../skills/fix-analyzer-bug/references/changelog-examples.md | 3 ++- ChangeLog.md | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.claude/skills/fix-analyzer-bug/SKILL.md b/.claude/skills/fix-analyzer-bug/SKILL.md index 1a0bdbd425..54c9e966dc 100644 --- a/.claude/skills/fix-analyzer-bug/SKILL.md +++ b/.claude/skills/fix-analyzer-bug/SKILL.md @@ -66,7 +66,9 @@ Fixes #NNNN Use `Fixes #NNNN` or `Closes #NNNN`. A markdown link such as `[#1812](https://github.com/dotnet/roslynator/issues/1812)` does **not** create a GitHub issue reference and will not auto-close the issue. -Place it after the Summary bullets and before the Test plan, for example: +In `ChangeLog.md`, end the entry with `([PR](https://github.com/dotnet/roslynator/pull/NNNN))` (see [references/changelog-examples.md](references/changelog-examples.md)). Do not use an issue link there. + +Place `Fixes #NNNN` after the Summary bullets and before the Test plan, for example: ```markdown ## Summary @@ -90,4 +92,5 @@ Fixes #1812 | Full test suite | Filter by rule id is enough | | Skip test | CONTRIBUTING.md requires tests for bug fixes | | `CHANGELOG.md` | `ChangeLog.md` at repo root | +| Changelog ends with issue link (`[#NNNN](.../issues/...)`) | End with `([PR](https://github.com/dotnet/roslynator/pull/NNNN))` | | Markdown-only issue link in PR body | Use `Fixes #NNNN` so GitHub links and auto-closes the issue | diff --git a/.claude/skills/fix-analyzer-bug/references/changelog-examples.md b/.claude/skills/fix-analyzer-bug/references/changelog-examples.md index 575ec7024b..191b6b6762 100644 --- a/.claude/skills/fix-analyzer-bug/references/changelog-examples.md +++ b/.claude/skills/fix-analyzer-bug/references/changelog-examples.md @@ -32,4 +32,5 @@ Prefix with `[CLI]`. - Link id to docs URL - Plain-language behavior change - Backticks for code identifiers -- PR link when known +- End with `([PR](https://github.com/dotnet/roslynator/pull/NNNN))` — not an issue link (`[#NNNN](.../issues/...)`) +- After the PR exists, update the changelog entry if it was drafted without the PR URL diff --git a/ChangeLog.md b/ChangeLog.md index fec6e383ff..79819ae530 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fix analyzer [RCS0036](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0036) to report blank lines between single-line declarations in records ([#1812](https://github.com/dotnet/roslynator/issues/1812)) +- Fix analyzer [RCS0036](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0036) to report blank lines between single-line declarations in records ([PR](https://github.com/dotnet/roslynator/pull/1813)) - Fix analyzer [RCS1046](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1046) to report `async void` methods without `Async` suffix ([PR](https://github.com/dotnet/roslynator/pull/1790)) - Fix analyzer [RCS1265](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1265) to not report catch clauses with a `when` filter ([PR](https://github.com/dotnet/roslynator/pull/1789)) - Fix analyzer [RCS0034](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0034) for types with a primary constructor and multiple constraint clauses ([PR](https://github.com/dotnet/roslynator/pull/1791))