Skip to content

fix: CS8604 nullable warning in TodoApp.Avalonia LoggingHandler#544

Open
TemRevil wants to merge 2 commits into
CommunityToolkit:mainfrom
TemRevil:fix/avalonia-logginghandler-nullable
Open

fix: CS8604 nullable warning in TodoApp.Avalonia LoggingHandler#544
TemRevil wants to merge 2 commits into
CommunityToolkit:mainfrom
TemRevil:fix/avalonia-logginghandler-nullable

Conversation

@TemRevil

Copy link
Copy Markdown

Fixes #520

WriteContentAsync declared a non-nullable HttpContent parameter, but both call sites pass HttpContent? (request.Content and response.Content), so every TodoApp.Avalonia build logged CS8604 once the samples gained CI coverage in #511/#519.

As suggested in the issue, the parameter is now HttpContent? — the method already null-checks, so there is no behavior change.

Verified with dotnet build on the TodoApp.Avalonia project (net10.0): build succeeds with zero CS8604 warnings.

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.
@TemRevil

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

private static async Task WriteContentAsync(HttpContent content, CancellationToken cancellationToken = default)
private static async Task WriteContentAsync(HttpContent? content, CancellationToken cancellationToken = default)
{
if (content != null)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since content is now not nullable, the if (content != null) on line 40 is no longer required and can be replace by an Assert statement.

@adrianhall

Copy link
Copy Markdown
Collaborator

Overall - love the change - congrats on your first resolution.

Decide whether you want to fix the small change suggested and let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CS8604 nullable-reference warning in TodoApp.Avalonia's LoggingHandler.WriteContentAsync

2 participants