Open
Description
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 forJsonTypeInfoKind.Enumerable
- A
Func<IDictionary, object>>? CreateDictionary
delegate forJsonTypeInfoKind.Dictionary
.- A
Func<object[], object>? CreateObjectWithParameters
delegate for invoking parameterized constructors inJsonTypeInfoKind.Object
.Note that these would require exposing the
JsonTypeInfo.ElementType
andJsonTypeInfo.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:
- System.Text.Json contract customization ignoring custom
CreateObject
delegates in certain collection types #73382 - System.Text.Json does not support constructors with byref parameters. #46088
- Expose information about JsonPropertyInfo being readable/writable #77307
- S.T.J.JsonSerializer doesn't support properties marked with JsonRequiredAttribute that're initialized through ctor #78098
- [JsonSerializer] Relax restrictions on ctor param type to immutable property type matching where reasonable #44428
- JsonSerializer.Serialize an anonymous type, with duplicate nested names throws an unexpected exception #81550