Home

Async lambda autocomplete doesn't recognize Task wrapper.

When you create an async lambda with implicit typing (as in a LINQ statement) then LINQPad thinks the return value of the method is `T` rather than `Task` when it comes to autocomplete suggestions.

image

In the above code, LINQPad thinks that `i` is a bool when it's really a Task and it shows you autocomplete suggestions for booleans. When you try to compile/run, it obviously throws an error and, although not suggested by autocomplete, you can still write `i.Result == true` and it will compile and run fine.

Comments

  • Oh, and I'm using LINQPad v4.53.16 (AnyCPU) with an activated Premium Edition.

    So you can replicate the issue:
    var items = new[] {1, 2, 3, 4, 5, 6};
    items.Select(async (i) => {
    await Task.Delay(10);
    return i > 3;
    })
    .Count(i => i.Result == true)
    .Dump();
Sign In or Register to comment.