跳到正文
FunCoding

fix-analyzer-bug

官方

Use when fixing a Roslynator analyzer false positive or false negative, RCS####, RR####, or CS####/RCF#### regression, incorrect diagnostic reporting, or bug report citing a specific rule id — not when adding new rules.

Star
3,506
最近提交
2026年11月1日

.claude/skills/fix-analyzer-bug/SKILL.md

在 GitHub 上查看

Fix Analyzer Bug

Overview

Reproduce in an existing test file, minimal code fix, changelog entry. Highest-frequency contributor task.

When to Use

  • Analyzer reports when it should not (false positive)
  • Analyzer misses case it should report (false negative)
  • Code fix produces wrong transformation
  • Issue title includes RCS####, RR####, CS####, or RCF####

Not for: new rules (add-analyzer, add-refactoring, add-compiler-diagnostic-fix), deprecation (deprecate-analyzer-or-refactoring).

For test patterns use in-repo verifiers — not public NuGet testing docs.

Quick Reference

PrefixCodeTestsVerifier
RCS1Analyzers/CSharp/Analysis/Tests/Analyzers.Tests/AbstractCSharpDiagnosticVerifier
RCS0Formatting.Analyzers/CSharp/Tests/Formatting.Analyzers.Tests/AbstractCSharpDiagnosticVerifier
RCS9CodeAnalysis.Analyzers/CSharp/Tests/CodeAnalysis.Analyzers.Tests/AbstractCSharpDiagnosticVerifier
RRRefactorings/CSharp/Refactorings/Tests/Refactorings.Tests/AbstractCSharpRefactoringVerifier
CS / RCFCodeFixes/CSharp/CodeFixes/Tests/CodeFixes.Tests/AbstractCSharpCompilerDiagnosticFixVerifier

Search DiagnosticIdentifiers.X / DiagnosticRules.X / CompilerDiagnosticIdentifiers.* in generated files. Roslynator analyzer code fixes live in matching .CodeFixes projects.

Implementation

Add [Fact] to existing *Tests.cs — new file only if none exists.

CaseMethod
False positiveVerifyNoDiagnosticAsync
False negativeVerifyDiagnosticAsync with `[
Analyzer/refactoring fix regressionVerifyDiagnosticAndFixAsync
Compiler fix regressionVerifyFixAsync (no `[

Config-dependent: options: Options.AddConfigOption(...).

Verify (adjust project and filter):

cd src && dotnet build Roslynator.sln
cd src && dotnet test Tests/Analyzers.Tests --no-build --filter "FullyQualifiedName~RCS####"
cd src && dotnet test Tests/CodeFixes.Tests --no-build --filter "FullyQualifiedName~CS####"
cd src && dotnet format Roslynator.sln --no-restore --verify-no-changes --severity info

Changelog examples: 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):

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.

In CHANGELOG.md, end the entry with ([PR](https://github.com/dotnet/roslynator/pull/NNNN)) (see 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:

## Summary
- …

Fixes #1812

## Test plan
- …

Common Mistakes

MistakeFix
Copy test pattern from analyzers-testing.mdIn-repo AbstractCSharpDiagnosticVerifier + DiagnosticRules.X
Copy from compiler-diagnostic-fixes-testing.mdIn-repo AbstractCSharpCompilerDiagnosticFixVerifier + CompilerDiagnosticIdentifiers.*
New test file per caseExtend existing RCS####...Tests.cs or CS####...Tests.cs
Change Analyzers.xml for logic bugsMetadata only for docs/severity defaults
`[...
Full test suiteFilter by rule id is enough
Skip testCONTRIBUTING.md requires tests for bug fixes
Changelog ends with issue link ([#NNNN](.../issues/...))End with ([PR](https://github.com/dotnet/roslynator/pull/NNNN))
Markdown-only issue link in PR bodyUse Fixes #NNNN so GitHub links and auto-closes the issue

相似的 Skill

rea-analysis-optimization

MOmorluto/rea485k近 7 天新增 9,215 个 star

codebase-design

MAmattpocock/skills336k近 7 天新增 5,004 个 star

精选

diagnosing-bugs

诊断困难 bug 和性能回归,用测试或脚本构建反馈循环定位问题。

MAmattpocock/skills336k近 7 天新增 5,004 个 star

setup-ts-deep-modules

MAmattpocock/skills336k近 7 天新增 5,004 个 star

code-review

MAmattpocock/skills336k近 7 天新增 5,004 个 star

implement

MAmattpocock/skills336k近 7 天新增 5,004 个 star