You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose information about JsonPropertyInfo being readable/writable #77307
It's very useful information to know if property is readable/writable (i.e. generating docs). But this information is currently not exactly obvious.
If JsonPropertyInfo.Get != null then we know property is readable
If JsonPropertyInfo.Set != null then we know property is writable
but above is not complete:
If JsonPropertyInfo.Get != null and there is parametrized ctor with related property property is also writable (technically it's init but that's transparent to user)
while first two are easy to check the last one is not exactly trivial due to this information not being exposed.
Somewhat related to #71944 - it could potentially be solved as part of that issue but this issue is much more scoped than that.
It will largely depend on how #71944 gets implemented. Clearly, we need to expose JsonParameterInfo. Currently the implementation requires each parameter to be bound to a corresponding JsonPropertyInfo, however this is only required for validating that each parameter corresponds to a property and is not strictly necessary for deserialization to succeed.
We have received feedback from users who believe that the current restriction is too strict, so perhaps it makes sense to completely decouple JsonPropertyInfo from JsonParameterInfo, at least in the contract model layer. If we do it that way, then clearly a property is writeable only if it defines a setter.
@eiriktsarpalis I think I'd go the other way - from JSON point of view there are really no parameters. Only serialization has such concept - I'd rather go in direction of adding bool flag on the JsonPropertyInfo, i.e. IsConstructorParameter or nullable ConstructorParameterName and internally we can still do what we used to. IMO JsonTypeInfo.Properties should be exhaustive list of what can occur in the payload
I'd rather go in direction of adding bool flag on the JsonPropertyInfo
Note that ordering of constructor parameters is significant and might not match the declared serialization order (which is also influenced by the Order property). Assuming we fix #44428, it may well be the case that the type of JsonParameterInfo does not match the type of the corresponding JsonPropertyInfo.
Activity
eiriktsarpalis commentedon Oct 21, 2022
It will largely depend on how #71944 gets implemented. Clearly, we need to expose
JsonParameterInfo. Currently the implementation requires each parameter to be bound to a correspondingJsonPropertyInfo, however this is only required for validating that each parameter corresponds to a property and is not strictly necessary for deserialization to succeed.We have received feedback from users who believe that the current restriction is too strict, so perhaps it makes sense to completely decouple
JsonPropertyInfofromJsonParameterInfo, at least in the contract model layer. If we do it that way, then clearly a property is writeable only if it defines a setter.krwq commentedon Oct 21, 2022
changing milestone to 8.0 - we should at least consider this for 8.0
krwq commentedon Oct 21, 2022
@eiriktsarpalis I think I'd go the other way - from JSON point of view there are really no parameters. Only serialization has such concept - I'd rather go in direction of adding bool flag on the JsonPropertyInfo, i.e.
IsConstructorParameteror nullableConstructorParameterNameand internally we can still do what we used to. IMO JsonTypeInfo.Properties should be exhaustive list of what can occur in the payloadeiriktsarpalis commentedon Oct 21, 2022
Note that ordering of constructor parameters is significant and might not match the declared serialization order (which is also influenced by the
Orderproperty). Assuming we fix #44428, it may well be the case that the type of JsonParameterInfo does not match the type of the corresponding JsonPropertyInfo.