Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfiguredAsyncEnumerable in netcoreapp3.0 preview is not acceptable with await foreach (CS8142)? #31609

Closed
yyjdelete opened this issue Dec 7, 2018 · 4 comments
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Feature - Async Streams Async Streams
Milestone

Comments

@yyjdelete
Copy link

Version Used: The one in VS2019 Preview1 and dotnet sdk 3.0.100-preview-009812

Steps to Reproduce:

  1. using System.Threading.Tasks;
  2. await foreach (var z in /IAsyncEnumerable/.ConfigureAwait(false))

Expected Behavior:
See this on https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md but seems not see this on #24037, is it still available?

Actual Behavior:
CS8412

@jaredpar
Copy link
Member

jaredpar commented Jan 2, 2019

@yyjdelete can you clarify what error you're getting here? It's unclear from the bug what the actual error is.

@jaredpar jaredpar added the Need More Info The issue needs more information to proceed. label Jan 2, 2019
@yyjdelete
Copy link
Author

yyjdelete commented Jan 3, 2019

Expected Behavior:

Build successful with no errors.

Actual Behavior:

Error CS8412 Async foreach requires that the return type 'ConfiguredAsyncEnumerable.Enumerator' of 'ConfiguredAsyncEnumerable.GetAsyncEnumerator()' must have a suitable public 'MoveNextAsync' method and public 'Current' property

Nightly builds of dotnet-sdk/roslyn is not tested.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>8.0</LangVersion>
  </PropertyGroup>

</Project>
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }

        public async Task Test2()
        {
            await foreach(var x in Test())
            {
            }

            await foreach (var x in Test().ConfigureAwait(false))
            {
            }
        }

        public IAsyncEnumerable<int> Test() => null;
    }
}

@jcouv jcouv self-assigned this Jan 8, 2019
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Jan 8, 2019
@jcouv jcouv added this to the 16.0.P2 milestone Jan 8, 2019
@jcouv
Copy link
Member

jcouv commented Jan 8, 2019

Thanks for reporting this and for the details. A fix is pending review for preview2.

@jcouv jcouv removed the Need More Info The issue needs more information to proceed. label Jan 8, 2019
@jcouv
Copy link
Member

jcouv commented Jan 16, 2019

Fix merged for preview2.
Note there is a related issue which is not fixed yet. When you use ConfigureAwait in an await foreach loop, we'll don't call its DisposeAsync() method. Tracked by #32316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Feature - Async Streams Async Streams
Projects
None yet
Development

No branches or pull requests

4 participants