Skip to content

Add additional test for STJ Schema deprecated property#131189

Open
Youssef1313 wants to merge 2 commits into
mainfrom
dev/ygerges/extend-test
Open

Add additional test for STJ Schema deprecated property#131189
Youssef1313 wants to merge 2 commits into
mainfrom
dev/ygerges/extend-test

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Only adds additional test coverage. It occurred to me that I could have got this scenario wrong when I added deprecated implementation in #130665, but turned out to be correct already. So I thought it's worth adding a test.

Basically, we want to ensure that for the following case, we don't end up re-using the same $ref for the two properties. Only Deprecated should get the deprecated property.

public sealed class PocoWithObsoletePropertiesSharingType
{
    public PocoSharedByObsoleteMembers? NotDeprecated { get; set; }

    [Obsolete]
    public PocoSharedByObsoleteMembers? Deprecated { get; set; }
}

@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.

Pull request overview

Adds targeted System.Text.Json JsonSchemaExporter test coverage to ensure the deprecated keyword is applied only to obsolete members in scenarios where schema nodes/types could otherwise be shared (including $ref reuse paths).

Changes:

  • Adds a new test case covering two properties sharing the same POCO type, where only the obsolete property’s schema should be marked deprecated.
  • Adds a new test case covering two collection properties sharing a $ref’d element schema, ensuring deprecated does not leak into the shared referenced schema.
  • Introduces small POCO helper types used by the new test cases.

Copilot AI review requested due to automatic review settings July 26, 2026 09:34

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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.

3 participants