Skip to content

[System.Text.Json] Allow TimeOnly as Dictionary key #77566

@maxkoshevoi

Description

@maxkoshevoi

Description

Currently (.NET 7 RC2) both DateTime and DateOnly are allowed as Dictionary keys, but not TimeOnly. This seems strange.

image
image
image

Reproduction Steps

Try returning Dictionary that has at least one item with TimeOnly as a key from an API action.

Expected behavior

Getting the serialized response

Actual behavior

Exception

Regression?

No

Known Workarounds

Creating custom convertor

Configuration

.NET 7 RC2

Other information

No response

Metadata

Metadata

Labels

area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionsin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions