You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CS8604 nullable-reference warning in TodoApp.Avalonia's LoggingHandler.WriteContentAsync #520
Surfaced by the new mobile-heads CI added in #511 (PR #519), specifically the TodoApp.Avalonia.iOS build:
Warning: .../samples/todoapp/TodoApp.Avalonia/TodoApp.Avalonia/Services/LoggingHandler.cs(28,33):
warning CS8604: Possible null reference argument for parameter 'content' in
'Task LoggingHandler.WriteContentAsync(HttpContent content, CancellationToken cancellationToken = default(CancellationToken))'.
This is a pre-existing nullable-reference warning, not something introduced by #511/#519 - it just hadn't been surfaced by CI before since /samples had no CI coverage until Phase 1 (#509).
protectedoverrideasyncTask<HttpResponseMessage>SendAsync(HttpRequestMessagerequest,CancellationTokencancellationToken){...
await WriteContentAsync(request.Content,cancellationToken);// request.Content is HttpContent?...
await WriteContentAsync(response.Content,cancellationToken);// response.Content is HttpContent?...}privatestaticasyncTaskWriteContentAsync(HttpContentcontent,CancellationTokencancellationToken=default){if(content!=null){Debug.WriteLine($"[HTTP] >>> {awaitcontent.ReadAsStringAsync(cancellationToken)}");}}
HttpRequestMessage.Content and HttpResponseMessage.Content are both HttpContent? (nullable), but WriteContentAsync's content parameter is declared as non-nullable HttpContent. The method already null-checks internally (if (content != null)), so the nullable annotation on the parameter is simply wrong/stale - the compiler is correctly flagging that callers can pass null even though the signature claims they can't.
Only line 28 (request.Content) is called out in the log because MSBuild only reported the first occurrence per build, but response.Content on line 32 has the identical issue.
Suggested fix
Change the parameter to nullable to match actual usage:
No behavior change - the method already handles null correctly.
Impact
Low - this is a warning, not a build-breaking error (this repo does not set TreatWarningsAsErrors anywhere), so it doesn't currently fail any CI job. Worth cleaning up since it will otherwise show up as noise in every TodoApp.Avalonia mobile/desktop CI build going forward (build-samples-todoapp-avalonia.yml, all three jobs) now that #511 covers all of that sample's heads.
Activity