Skip to content

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

Open

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:

Activity

  1. ghost added
    untriaged
    on Jul 11, 2022
  2. added this to the 8.0.0 milestone on Jul 11, 2022
  3. ghost removed
    untriaged
    on Jul 11, 2022
  4. added
    api-suggestion
    on Jul 11, 2022
  5. added
    User Story
    Cost:L
    on Sep 2, 2022
  6. modified the milestones: 8.0.0, Future on Jan 25, 2023
  7. changed the title [-]Add support for parameterized constructors in System.Text.Json contract customization[/-] [+]Add support for parameterized constructors in System.Text.Json contract customization (converters)[/+] on Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Cost:LUser Storyapi-suggestionarea-System.Text.Json

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions