Skip to content

[S.T.J] Fix PropertyRef.Equals - #133027

Merged
jozkee merged 2 commits into
dotnet:mainfrom
jozkee:propertyref
Sep 2, 2026
Merged

[S.T.J] Fix PropertyRef.Equals #133027
jozkee merged 2 commits into
dotnet:mainfrom
jozkee:propertyref

Conversation

@jozkee

@jozkee jozkee commented Sep 1, 2026

Copy link
Copy Markdown
Member

To compare name if this.Utf8PropertyName is also > PropertyNameKeyLength.

@jozkee jozkee added this to the 12.0.0 milestone Sep 1, 2026
@jozkee jozkee self-assigned this Sep 1, 2026
Copilot AI lite review requested due to automatic review settings September 1, 2026 17:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Pull request overview

Fixes an equality bug in System.Text.Json’s UTF-8 property-name cache where a short property name (≤7 bytes) could incorrectly match a cached long property name that happens to share the same embedded key (due to the key encoding truncating length to one byte).

Changes:

  • Update PropertyRef.Equals(ReadOnlySpan<byte>, ulong) to only skip full byte comparison when both property names fit in the embedded-key format (≤7 bytes).
  • Add a regression test that constructs two names with the same computed key but different lengths and verifies they remain distinct in the property cache.
File summaries
File Description
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/PropertyRef.cs Tightens equality logic to avoid false positives when key collisions occur between short and long UTF-8 names.
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CacheTests.cs Adds coverage for the key-collision scenario to prevent regressions in property cache lookups.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 1, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

@jozkee

jozkee commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@jozkee

jozkee commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

@jozkee

jozkee commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

/backport to release/9.0-staging

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/9.0-staging (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants