-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[release/9.0] Make GetPropertyCount public and fix its return value #106576
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
Conversation
…me at every object node
Also added checks for `GetArrayLength`
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
All release/9.0 PRs are currently only requiring M2 approval. @artl93 (or maybe @jeffschwMSFT at the moment)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved. please get a code review. this can be merged when ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and is approved for 9.0 RC2 once CI is green.
All requirements met. Merging now. |
Backport of #106503 to release/9.0
/cc @eiriktsarpalis @etemi
Customer Impact
The implementation of the new
JsonElement.DeepEquals
in .NET 9 makes use of the internalJsonElement.GetPropertyCount()
to short-circuit equality checks for two JSON objects. In a subsequent PR for .NET 10 that makes theGetPropertyCount()
method public it was discovered that the method reports inaccurate information (the number of total tokens contained within an object as opposed to the number of properties).While this inaccuracy doesn't impact functional correctness for equality comparison (if two JSON objects are equal, they always contain an equal number of tokens) it does impact performance, as it can force recursive equality checks for objects containing different numbers of properties.
It should be noted that this change adds new API (
JsonElement.GetPropertyCount()
) which makes testing for the correct behavior possible.Regression
Testing
Added unit testing validating that the correct property counts are being returned.
Risk
Low. Fixes a straightforward omission in the calculation of
JsonElement
object sizes that was not being used until .NET 9.