-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Adding JsonIgnoreAttribute to new
property fails with ArgumentException
#76268
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionusing System.Text.Json; ClassB b = new ClassB(); public class ClassA public class ClassB : ClassA 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. |
new
property fails with ArgumentException
new
property fails with ArgumentExceptionnew
property fails with ArgumentException
Description
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.
The text was updated successfully, but these errors were encountered: