Skip to content

C# oneOf wrappers: preserve payload data when discriminator is absent - #7998

Draft
gavinbarron with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-oneof-deserialization-issue
Draft

C# oneOf wrappers: preserve payload data when discriminator is absent#7998
gavinbarron with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-oneof-deserialization-issue

Conversation

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

C# oneOf wrappers without a discriminator could deserialize into an IComposedTypeWrapper with all typed members unset, dropping object payload fields with no fallback access path. This change preserves that data by enabling AdditionalData on composed wrappers.

  • Wrapper fallback for discriminator-less oneOf

    • Updated C# refiner flow to add serialization members with includeAdditionalProperties: true for model classes representing composed wrappers (OriginalComposedType != null).
    • This gives generated wrappers an AdditionalData bag and IAdditionalDataHolder, so unknown/unmapped payload fields remain accessible instead of being discarded.
  • Targeted regression coverage

    • Extended C# refiner union-wrapper test to assert composed wrappers now:
      • contain an AdditionalData property
      • implement IAdditionalDataHolder
  • Behavior impact

    • No discriminator/mapping logic was altered.
    • Change is scoped to C# composed wrapper models and only adds fallback data preservation.
// Before (discriminator-less object oneOf):
effect.Props.AddLoyaltyPointsEffectProps == null;
// payload fields were effectively lost

// After:
effect.Props.AddLoyaltyPointsEffectProps == null; // still possible
var raw = effect.Props.AdditionalData;            // payload preserved here

Copilot AI requested review from Copilot and removed request for Copilot July 27, 2026 21:57
Copilot AI changed the title [WIP] Fix C# oneOf deserialization loss of data without discriminator C# oneOf wrappers: preserve payload data when discriminator is absent Jul 27, 2026
Copilot AI requested a review from gavinbarron July 27, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C# oneOf deserialization silently loses data when no discriminator is defined

2 participants