Skip to content

System.Linq.Async is being assimilated into .NET 10 but System.Linq.AsyncEnumerable doesn't seem to be on parity and breaks pre-.NET 10 code. #49162

Closed
@Xen0byte

Description

@Xen0byte

Describe the bug

It seems like async lambdas are no longer supported in System.Linq.AsyncEnumerable in .NET 10 but at the same time the compiler will raise an ambiguous reference error if System.Linq.Async is installed.

To Reproduce

previously, with System.Linq.Async, something along the lines of the following was possible

int number = await new List<int>() { 1, 2, 3 }.ToAsyncEnumerable()
    .SingleAwaitAsync(async (value) => { await Task.Delay(500); return value.Equals(2); });

however, with System.Linq.AsyncEnumerable, the equivalent doesn't compile

int number = await new List<int>() { 1, 2, 3 }.ToAsyncEnumerable()
    .SingleAsync(async (value) => { await Task.Delay(500); return value.Equals(2); });

Exceptions (if any)

Cannot convert async lambda expression to delegate type 'Func<int, bool>'.
An async lambda expression may return void, Task or Task<T>, none of which are convertible to 'Func<int, bool>'.

Further technical details

  • Visual Studio Enterprise 2022 (64-bit) 17.14.2 Preview 1.0
  • .NET 10.0.100-preview.4.25258.110

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions