Skip to content

Add support for parameterized constructors in System.Text.Json contract customization (converters) #71944

Open
@eiriktsarpalis

Description

@eiriktsarpalis

Taken from #63686 (comment):

The internal converters for collection and dictionary types do provide similar functionality, and we might consider exposing dedicated constructor delegates for each kind:

  • A Func<IList, object>>? CreateEnumerable delegate for JsonTypeInfoKind.Enumerable
  • A Func<IDictionary, object>>? CreateDictionary delegate for JsonTypeInfoKind.Dictionary.
  • A Func<object[], object>? CreateObjectWithParameters delegate for invoking parameterized constructors in JsonTypeInfoKind.Object.

Note that these would require exposing the JsonTypeInfo.ElementType and JsonTypeInfo.KeyType properties, respectively. The parameterized constructor delegate would require exposing the internal [JsonParameterInfo]
#78098 metadata type.

Related bugs that should be addressed in conjunction with this story:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Cost:LWork that requires one engineer up to 4 weeksUser StoryA single user-facing feature. Can be grouped under an epic.api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Json

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions