Skip to content

docs(examples): correctness cleanup — static helpers, dispose CTS, dedup interfaces - #377

Merged
Chris-Wolfgang merged 1 commit into
vNextfrom
fix/inspectcode-correctness-examples
Aug 14, 2026
Merged

Chris-Wolfgang merged 1 commit into
vNextfrom
fix/inspectcode-correctness-examples

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Stacked PR 6 on the Code Scanning cleanup — example-code correctness. Base: fix/inspectcode-correctness-test-src (PR #376).

Fixes (also make the demos model better practice) — 68 alerts

  • RCS1102 ×23 — const-only ConsoleColors / static-only helpers → static class.
  • S2930 ×10 — var cts = new CancellationTokenSource(...) → using var so the examples demonstrate proper CancellationTokenSource disposal.
  • RedundantExtendsListEntry ×16 + S1939 ×16 (same lines) — drop the redundant base interface from the base list (IExtractWithProgressAsync<…> already derives from IExtractAsync<…>, etc.).
  • RedundantNullableDirective ×3 — drop redundant file-level #nullable.

Dismissed — false-positive / readability-preferred in a demo (65 alerts)

  • AccessToModifiedClosure ×36 — the timer/progress closure intentionally captures the live counter (Volatile.Read(ref count)); that's the whole pattern.
  • S125 ×12 — deliberately illustrative commented code ("you can either throw… or handle gracefully").
  • S4456 ×17 — the eager-validation split would add boilerplate that hurts example readability; the lazy validation is fine in a demo.

Verification

Full-matrix dotnet build green (net462…net10.0). Diffs are surgical (50 files, +49/−52); behavior-preserving. Spot-checked: internal static class ConsoleColors, using var cts, FibonacciExtractor : IExtractWithProgressAsync<int, EtlProgress>.

🤖 Generated with Claude Code

…dup interfaces

Mechanical InspectCode fixes across the example projects that also make the
demos model better practice:

- RCS1102 (x23): const-only `ConsoleColors` / static-only helpers -> `static class`.
- S2930 (x10): `var cts = new CancellationTokenSource(...)` -> `using var` so the
  examples demonstrate proper CancellationTokenSource disposal.
- RedundantExtendsListEntry + S1939 (x16 lines): drop the redundant base
  interface from the base list (IExtractWithProgressAsync already derives from
  IExtractAsync, etc.).
- RedundantNullableDirective (x3): drop redundant file-level `#nullable`.

Verified: full-matrix `dotnet build` green (net462..net10.0). Behaviour-preserving.

The remaining example findings (AccessToModifiedClosure, S125, S4456) are
false-positive / readability-preferred and are dismissed in code scanning.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 21:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Base automatically changed from fix/inspectcode-correctness-test-src to vNext August 14, 2026 00:26
@Chris-Wolfgang
Chris-Wolfgang merged commit 905f106 into vNext Aug 14, 2026
2 checks passed
@Chris-Wolfgang
Chris-Wolfgang deleted the fix/inspectcode-correctness-examples branch August 14, 2026 00:29
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.

2 participants