Skip to content

SignalR: Using IAsyncEnumerable<T> and ChannelReader<T> with ValueTypes in native AOT #56179

Closed

Description

Image for: Description

With #56079, native AOT support for SignalR client was added. But one scenario that isn't supported is to use "streaming" APIs (IAsyncEnumerable<T> and ChannelReader<T>) with ValueTypes. In order to work with IAsyncEnumerable<T> and ChannelReader<T> we either need to "jump" to a <T> generic method (which is what it does today, and not supported with native AOT because it can't generate the code up front) or by using reflection to invoke the MoveNextAsync() and WaitToReadAsync() methods.

It was decided to not support this scenario until we get data that shows we need to implement this in SignalR.

Note that using ValueTypes in these scenarios isn't necessarily a performance gain because the T will be boxed (i.e. an allocation will occur) into the StreamItemMessage in:

while (!tokenSource.Token.IsCancellationRequested && reader.TryRead(out var item))
{
await SendWithLock(connectionState, new StreamItemMessage(streamId, item), tokenSource.Token).ConfigureAwait(false);

cc @BrennanConroy

Metadata

Image for: Metadata

Metadata

Image for: Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Image for: Issue actions