Skip to content

fix: ignore nameof-only token references in CC016 and CC017#32

Merged
georgepwall1991 merged 1 commit into
masterfrom
fix/token-nameof-not-observation
Jul 21, 2026
Merged

fix: ignore nameof-only token references in CC016 and CC017#32
georgepwall1991 merged 1 commit into
masterfrom
fix/token-nameof-not-observation

Conversation

@georgepwall1991

Copy link
Copy Markdown
Owner

Summary

  • ignore token references contained by Roslyn INameOfOperation
  • restore CC016 for async methods whose token appears only in nameof
  • restore CC017 for BackgroundService loops whose stopping token appears only in nameof
  • preserve runtime references in nested lambdas and local functions
  • prepare v1.27.177 release metadata

Why

nameof(token) is evaluated at compile time and cannot observe cancellation. The shared reference helper treated it as runtime usage, hiding real ignored-token defects in both rules.

Validation

  • two red-first regressions reproduced both false negatives
  • focused CC016/CC017 tests: 17 passed
  • full suite: 632 passed, 0 failed
  • Release build: 0 errors (62 intentional sample analyzer warnings)
  • touched-file whitespace verification: clean
  • package inspection: both analyzer assemblies present; no NuGet dependencies
  • self-review completed as requested; no Claude review used

Tooling note

Slopwatch is required by the local .NET overlay but is not installed on this host; each attempt returned command not found. Manual hygiene and exact-diff review are clean.

A token mentioned only through nameof has no runtime effect. Excluding those compile-time references restores CC016 and CC017 diagnostics without changing genuine token observation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant