Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
6 tasks
Tracked by #71967
eiriktsarpalis opened this issue Jul 11, 2022 · 1 comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Text.Json Cost:L Work that requires one engineer up to 4 weeks User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Jul 11, 2022

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:

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 11, 2022
@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jul 11, 2022
@ghost
Copy link

ghost commented Jul 11, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

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 metadata type.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jul 11, 2022
@eiriktsarpalis eiriktsarpalis added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jul 11, 2022
@eiriktsarpalis eiriktsarpalis added User Story A single user-facing feature. Can be grouped under an epic. Cost:L Work that requires one engineer up to 4 weeks labels Sep 2, 2022
@krwq krwq modified the milestones: 8.0.0, Future Jan 25, 2023
@krwq krwq 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) Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Text.Json Cost:L Work that requires one engineer up to 4 weeks User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

2 participants