docs(examples): correctness cleanup — static helpers, dispose CTS, dedup interfaces - #377
Merged
Merged
Conversation
…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>
4 tasks
This was referenced Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-onlyConsoleColors/ static-only helpers →static class.S2930×10 —var cts = new CancellationTokenSource(...)→using varso the examples demonstrate properCancellationTokenSourcedisposal.RedundantExtendsListEntry×16 +S1939×16 (same lines) — drop the redundant base interface from the base list (IExtractWithProgressAsync<…>already derives fromIExtractAsync<…>, 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 buildgreen (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