Skip to content

SignalR's JSON protocol does not support polymorphic serialization on streaming methods #54227

Closed
@Tragetaschen

Description

@Tragetaschen

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In #47859, most of ASP.NET Core learned to serialize a polymorphic JSON hierarchy, but SignalR was omitted and still doesn't include the type discriminator declared on the base type, for example when streaming from server to client.

It would be great if this difference would not exist.

For me, the workaround of declaring the derived classes [JsonPolymorphic] etc. works.

Expected Behavior

Streaming a base type from server to client should include the type discriminator.

Steps To Reproduce

public class MyHub: Hub
{
    public async IAsyncEnumerable<BaseMessage> GetMessages()
    {
        yield return new DerivedMessage();
    }
}

Exceptions (if any)

No response

.NET Version

8.0.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions