chore: pre-release polish (filename, versioned user-agent, SD parser pragmas)#227
Conversation
…pragmas) Three small cleanups bundled together: 1. Rename TestMessage.cs to TextMessage.cs to match its class — the file contained `class TextMessage` (a production message type), not test code. 2. Derive GitHubFirmwareDownloadService user-agent from the assembly version instead of a hardcoded "1.0", so GitHub rate-limit/abuse fingerprints move with each release. `const` becomes `static readonly` since the interpolation can't be evaluated at compile time. 3. Replace the no-op `await Task.CompletedTask;` shim in the SD parser IAsyncEnumerable iterators with `#pragma warning disable CS1998`. These methods need `async` to allow `yield return`, but have no real awaits; the pragma documents that intent explicitly and survives TreatWarningsAsErrors. Applied to the three production parser methods and the two `EmptySamples()` helpers in Json/Csv parsers for consistency. Closes #223 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review Summary by QodoPre-release polish: pragmas, versioned user-agent, filename fix
WalkthroughsDescription• Replace no-op await Task.CompletedTask with #pragma warning disable CS1998 in async iterators - Applied to three production parser methods and two EmptySamples() helpers - Makes async requirement explicit and survives TreatWarningsAsErrors • Derive user-agent version from assembly instead of hardcoded "1.0" - Ensures GitHub rate-limit fingerprints follow releases - Changed const to static readonly for runtime interpolation • Rename TestMessage.cs to TextMessage.cs for filename accuracy Diagramflowchart LR
A["SD Parser Iterators"] -->|"Replace await shim"| B["Pragma disable CS1998"]
C["GitHub Download Service"] -->|"Runtime version"| D["Dynamic user-agent"]
E["Test file"] -->|"Rename"| F["TextMessage.cs"]
B --> G["Cleaner intent"]
D --> G
F --> G
File Changes1. src/Daqifi.Core/Device/SdCard/SdCardCsvFileParser.cs
|
Code Review by Qodo
1.
|
…mVer suffix Per Qodo review on #227: `Assembly.GetName().Version` is numeric-only ("1.0.0.0") and truncates SemVer prerelease suffixes. The release workflow passes `/p:Version=1.0.0-beta.1` which sets `AssemblyInformationalVersion` but writes only `1.0.0.0` to `AssemblyVersion`, so prerelease builds would have been indistinguishable from stable ones in GitHub API traffic. Switch to `AssemblyInformationalVersionAttribute.InformationalVersion` with `AssemblyName.Version` as a fallback. Both are RFC 7231 user-agent token compliant (the `+` SourceLink suffix is allowed in product-version). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Response to @qodo-code-review1. User-agent loses prerelease suffix — Agreed, fixed in de53f6fGood catch. The release workflow passes Switched to private static string BuildDefaultUserAgent()
{
var assembly = typeof(GitHubFirmwareDownloadService).Assembly;
var version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
?? assembly.GetName().Version?.ToString()
?? "unknown";
return $"DaqifiFirmwareUpdater/{version}";
}All 995 tests still pass on net9.0 and net10.0. |
Summary
Three small, independent cleanups bundled together per #223:
TestMessage.cs→TextMessage.csso the filename matches the productionclass TextMessageinside. No other source-tree callers exist.GitHubFirmwareDownloadService— derive fromAssembly.GetName().Versionso GitHub rate-limit/abuse fingerprints follow releases instead of staying pinned at1.0. Required flippingconst→static readonlybecause the interpolation isn't compile-time.await Task.CompletedTask;(with weak// keep the method async-compatiblecomment) with#pragma warning disable CS1998around the iterator methods. These needasyncto allowyield returnbut have no real awaits; the pragma makes that intent explicit and survivesTreatWarningsAsErrors. Applied to the three production parser methods (ProduceSamples,ParseJsonLines,ParseCsvLines) and also the twoEmptySamples()helpers in Json/Csv parsers for in-file consistency.Closes #223
Test plan
dotnet buildclean on net9.0 + net10.0 withTreatWarningsAsErrorsenforceddotnet test— 995 passed, 0 failed (2 hardware-skipped) on both targets🤖 Generated with Claude Code