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
System.Text.Json IgnoreReadOnlyProperties not working for enumerables #80113
by setting IgnoreReadOnlyProperties to true, one would expect that only "MyProperty1" and "Collection1" would be serialized.
Collection2 Gets also serialized for whatever reason.
Properties of collections types that only have setters are not supported.
But should they?
I'm missing whats the point of the reasoning for not supporting that.
Something like .IgnoreReadOnlyEnumerables with false as a default would allow users to avoid this behaviour
Duplicate of #67514 and #37599. IIUC this is intentional behavior and collections are treated specially w.r.t. this flag. Changing this now would be a breaking change. We might consider solving this using a different flag that supersedes IgnoreReadOnlyProperties.
Duplicate of #67514 and #37599. IIUC this is intentional behavior and collections are treated specially w.r.t. this flag. Changing this now would be a breaking change. We might consider solving this using a different flag that supersedes IgnoreReadOnlyProperties.
Shouldn't this behaviour be made configurable from the options?
Activity
npp127 commentedon Jan 3, 2023
Properties of collections types that only have setters are not supported.
But should they?
I'm missing whats the point of the reasoning for not supporting that.
Something like .IgnoreReadOnlyEnumerables with false as a default would allow users to avoid this behaviour
krwq commentedon Jan 17, 2023
I'm marking this as 8.0 for now because we should define behavior for this in #78556 and they should be looked at hollistically
eiriktsarpalis commentedon Jan 17, 2023
Duplicate of #67514 and #37599. IIUC this is intentional behavior and collections are treated specially w.r.t. this flag. Changing this now would be a breaking change. We might consider solving this using a different flag that supersedes
IgnoreReadOnlyProperties.npp127 commentedon Jan 17, 2023
Shouldn't this behaviour be made configurable from the options?
eiriktsarpalis commentedon Jun 16, 2023
Moving to Future.
wiz0u commentedon Dec 16, 2023
Same for getter-only arrays. They get serialized, even though they are obviously not deserializable (can't set or resize the array)
My test program: