chore: eliminate CA2024 warnings and enforce TreatWarningsAsErrors#225
Merged
Conversation
…loses #220) - Drive the SD-card JSON and CSV read loops off ReadLineAsync's null return rather than the synchronous EndOfStream property, resolving the two CA2024 warnings emitted on net10.0. - Enable <TreatWarningsAsErrors>true</TreatWarningsAsErrors> in both Daqifi.Core and Daqifi.Core.Tests so any new warning fails the build instead of accumulating. - Cancellation now surfaces from ReadLineAsync(ct) as TaskCanceledException (a subclass of OperationCanceledException). The two cancellation tests now use Assert.ThrowsAnyAsync<OperationCanceledException> to accept either type. External callers using `catch (OperationCanceledException)` are unaffected. Verified: dotnet build -c Release --no-incremental → 0 warnings on net9.0 and net10.0; all 993 tests pass on both target frameworks; a deliberate CS0414 probe confirmed the build now errors on warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review Summary by QodoEliminate CA2024 warnings and enforce TreatWarningsAsErrors
WalkthroughsDescription• Eliminate CA2024 warnings by refactoring read loops to use ReadLineAsync null return • Enable TreatWarningsAsErrors in both project files to prevent warning accumulation • Update cancellation tests to accept TaskCanceledException from async read operations • Improve code robustness by driving loop termination off async method return value Diagramflowchart LR
A["Read Loop Pattern"] -->|"Replace EndOfStream"| B["Use ReadLineAsync null return"]
B -->|"Refactor"| C["SdCardJsonFileParser.cs"]
B -->|"Refactor"| D["SdCardCsvFileParser.cs"]
E["Project Configuration"] -->|"Enable"| F["TreatWarningsAsErrors"]
F -->|"Apply to"| G["Daqifi.Core.csproj"]
F -->|"Apply to"| H["Daqifi.Core.Tests.csproj"]
I["Cancellation Handling"] -->|"Update tests"| J["Use ThrowsAnyAsync"]
J -->|"Accept"| K["OperationCanceledException subclasses"]
File Changes1. src/Daqifi.Core/Device/SdCard/SdCardJsonFileParser.cs
|
This was referenced May 30, 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.
Closes #220.
Summary
CA2024warnings (SdCardJsonFileParser.cs:45,SdCardCsvFileParser.cs:53) by driving the read loop offReadLineAsync's null return instead of the synchronousEndOfStreamproperty.<TreatWarningsAsErrors>true</TreatWarningsAsErrors>in bothDaqifi.Core.csprojandDaqifi.Core.Tests.csprojso new warnings fail the build instead of accumulating.Behavior note
Cancellation surfaces from
ReadLineAsync(ct)asTaskCanceledException(a subclass ofOperationCanceledException), where the old loop threwOperationCanceledExceptiondirectly viact.ThrowIfCancellationRequested(). Callers usingcatch (OperationCanceledException)are unaffected. The two cancellation tests were updated to useAssert.ThrowsAnyAsync<OperationCanceledException>so they accept either type.Test plan
dotnet build -c Release --no-incremental→0 Warning(s), 0 Error(s)on bothnet9.0andnet10.0.dotnet test -c Release→ 993 passed / 0 failed / 2 skipped on both target frameworks.CS0414(private field assigned but never used) — build correctly failed witherror CS0414instead of a warning. Probe file then removed.🤖 Generated with Claude Code