Skip to content

Support discriminated unions #64599

@captainsafia

Description

@captainsafia

C# is expected to add language-level discriminated unions, and we should prepare to support them end-to-end once the feature lands.

Impacted frameworks/tech: Minimal APIs, Blazor, SignalR, MVC, JSON Patch, OpenAPI

Key Areas to Address

  • Serialization handling
    Ensure discriminated unions work correctly as both input and result types. This includes model binding, JSON serialization, and any polymorphic scenarios.

  • Polymorphism support
    Verify that discriminated unions interoperate smoothly with existing polymorphic type handling in the framework and serializers.

  • OpenAPI integration
    Update OpenAPI generation so that discriminated union types are accurately represented in generated specs.

  • Source-generated & non-source-generated parity
    Confirm consistent behavior across both source-generated Minimal APIs and the non-source-generated RDF.

Goals

Achieve seamless usage of discriminated unions across the API surface so developers can use them naturally in Minimal APIs without workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Componentsarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcarea-signalrIncludes: SignalR clients and serversfeature-json-patchfeature-openapi

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions