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
Adding JsonIgnoreAttribute to new property fails with ArgumentException #76268
The above code will throw an exception: System.ArgumentException:“An item with the same key has already been added. Key: test”
When both base class and derived class has a property with the same name (derived class using new to override property in base class), and both of this two properties marked as [JsonIgnore], Serialize function throw this exception.
I can reproduce -- this belongs in the same class of bugs as #73255. This one is more interesting as it's actually failing with an exception during contract resolution.
changed the title [-]System.Text.Json.JsonSerializer.Serialize bug[/-][+]adding JsonIgnoreAttribute to `new` property fails with ArgumentException[/+]on Sep 28, 2022
changed the title [-]adding JsonIgnoreAttribute to `new` property fails with ArgumentException[/-][+]Adding JsonIgnoreAttribute to `new` property fails with ArgumentException[/+]on Sep 28, 2022
Activity
eiriktsarpalis commentedon Sep 28, 2022
I can reproduce -- this belongs in the same class of bugs as #73255. This one is more interesting as it's actually failing with an exception during contract resolution.
[-]System.Text.Json.JsonSerializer.Serialize bug[/-][+]adding JsonIgnoreAttribute to `new` property fails with ArgumentException[/+][-]adding JsonIgnoreAttribute to `new` property fails with ArgumentException[/-][+]Adding JsonIgnoreAttribute to `new` property fails with ArgumentException[/+]