Skip to content

The KeyValuePair converter should cache the converters for TKey and TValue #32148

@steveharter

Description

@steveharter

As part of #2259, the KeyValuePair converter was identified as an area of potential perf improvement. Currently (and in 3.0\3.1) it re-enters the serializer to serialize TKey and TValue which is expensive because a Dictionary lookup occurs for each (to find the converter).

Instead, the converter should cache the converter. Caching is possible on the converter instance since the type is internal and there are no concerns about having an instance shared across different JsonSerializerOptions instances that may have different converters for TKey and TValue.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions