Skip to content

Fix duplicate inherited discriminators in Java models - #11824

Draft
Xiaofei Cao (XiaofeiCao) wants to merge 3 commits into
microsoft:mainfrom
XiaofeiCao:fix-java-duplicate-discriminators
Draft

Fix duplicate inherited discriminators in Java models#11824
Xiaofei Cao (XiaofeiCao) wants to merge 3 commits into
microsoft:mainfrom
XiaofeiCao:fix-java-duplicate-discriminators

Conversation

@XiaofeiCao

@XiaofeiCao Xiaofei Cao (XiaofeiCao) commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary

  • merge redundant leaf discriminator declarations with propagated parent discriminators
  • validate that duplicate declarations have matching constant values and Java types
  • emit fixed propagated discriminator fields as final without changing shared serialization behavior
  • regenerate Java clientcore and generator-test golden models

Fixes #11802

Testing

  • Java generator build
  • Java emitter build
  • generator core tests (53 passed)
  • full http-client-generator-clientcore-test/Generate.ps1 regeneration
  • full http-client-generator-test/Generate.ps1 regeneration
  • Java formatting and lint checks

Merge redundant leaf discriminator declarations with propagated parent discriminators and preserve fixed discriminator fields as final.

Fixes microsoft#11802

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54b93dc2-48ce-4250-a6ea-5bd9b9a7ab2b
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

@typespec/http-client-java - fix ✏️

Prevent duplicate Java fields and accessors when a model redeclares an inherited fixed discriminator.

@azure-sdk-automation

azure-sdk-automation Bot commented Sep 2, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54b93dc2-48ce-4250-a6ea-5bd9b9a7ab2b
Keep active discriminators mutable so unknown values can round-trip through fallback deserialization, while fixed ancestor branch discriminators remain final.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 54b93dc2-48ce-4250-a6ea-5bd9b9a7ab2b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java emitter generates duplicate fixed discriminator members in Realtime message leaves

1 participant