Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 17, 2024

Backport of #106503 to release/9.0

/cc @eiriktsarpalis @etemi

Customer Impact

  • Customer reported
  • Found internally

The implementation of the new JsonElement.DeepEquals in .NET 9 makes use of the internal JsonElement.GetPropertyCount() to short-circuit equality checks for two JSON objects. In a subsequent PR for .NET 10 that makes the GetPropertyCount() 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

  • Yes
  • No

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.

@ghost
Copy link

ghost commented Aug 17, 2024

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

1 similar comment
@ghost
Copy link

ghost commented Aug 17, 2024

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

@carlossanlop
Copy link
Contributor

All release/9.0 PRs are currently only requiring M2 approval. @artl93 (or maybe @jeffschwMSFT at the moment)?

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a 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

Copy link
Member

@jeffhandley jeffhandley left a 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.

@artl93 artl93 added the Servicing-approved Approved for servicing release label Aug 23, 2024
@carlossanlop
Copy link
Contributor

All requirements met. Merging now.

@carlossanlop carlossanlop merged commit 980daff into release/9.0 Aug 27, 2024
85 of 90 checks passed
@carlossanlop carlossanlop deleted the backport/pr-106503-to-release/9.0 branch August 27, 2024 17:03
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants