Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public virtual bool CanHandle(MediaTypeHeaderValue accept)
public virtual Encoding GetEncoding(HttpRequest request)
{
var acceptCharset = request.GetTypedHeaders().AcceptCharset;
if (acceptCharset.Count > 0)
if (acceptCharset?.Count > 0)
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

acceptCharset?.Count > 0 produces a nullable boolean (because ?.Count is int?), which cannot be used directly as an if condition. This will fail to compile. Use a non-nullable condition (e.g., coalesce the count to 0, compare to true, or use a property pattern like checking acceptCharset is { Count: > 0 }).

Suggested change
if (acceptCharset?.Count > 0)
if (acceptCharset is { Count: > 0 })

Copilot uses AI. Check for mistakes.
Comment on lines 70 to +71
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

Consider adding a unit test for the reported scenario (no Accept-Charset header) to ensure GetEncoding returns the default encoding and does not throw. There are already GetEncoding_* tests in the test project, but none cover the missing-header case.

Copilot uses AI. Check for mistakes.
{
var preferred = acceptCharset
.OrderByDescending(x => x.Quality ?? 1.0)
Expand Down