Skip to content

Commit cab9b97

Browse files
TemReviladrianhall
andauthored
fix: CS8604 nullable warning in TodoApp.Avalonia LoggingHandler (#544)
* fix: CS8604 nullable warning in TodoApp.Avalonia LoggingHandler WriteContentAsync declared a non-nullable HttpContent parameter but both call sites pass HttpContent? (request.Content / response.Content), which raised CS8604 in every TodoApp.Avalonia CI build since the samples got CI coverage. The method already null-checks, so the parameter type just needed to match actual usage. * fix: assert instead of skip on null content in LoggingHandler request.Content and response.Content are never actually null in this sample app's flow, so the silent skip masked the case rather than surfacing it. Debug.Assert keeps the CS8604 fix from #544 while making an unexpected null loud instead of quiet, per review feedback. --------- Co-authored-by: Adrian Hall <photoadrian@outlook.com>
1 parent f8bc030 commit cab9b97

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

samples/todoapp/TodoApp.Avalonia/TodoApp.Avalonia/Services/LoggingHandler.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
3535
return response;
3636
}
3737

38-
private static async Task WriteContentAsync(HttpContent content, CancellationToken cancellationToken = default)
38+
private static async Task WriteContentAsync(HttpContent? content, CancellationToken cancellationToken = default)
3939
{
40-
if (content != null)
41-
{
42-
Debug.WriteLine($"[HTTP] >>> {await content.ReadAsStringAsync(cancellationToken)}");
43-
}
40+
Debug.Assert(content != null, "Request/response content should never be null here.");
41+
Debug.WriteLine($"[HTTP] >>> {await content.ReadAsStringAsync(cancellationToken)}");
4442
}
4543
}

0 commit comments

Comments
 (0)