Skip to content

Add AttributeTargets.Interface to JsonConverterAttribute #33112

Closed
@dlyz

Description

@dlyz

JsonConverterAttribute does not contain target AttributeTargets.Interface. I did not find any design notes about this behavior.

It's strange that JsonConverterAttribute can be applied to abstract classes, but not to interfaces.

In fact, JsonConverterAttribute can be used on property of an interface type, and it will work as expected. Also, specific JsonConverter that works with an interface type can be added to JsonSerializerOptions, and will work as expected.

Similar issue about enums: #30361

EDIT: See #33112 (comment) for the API proposal.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions