IAsyncEnumerable<> broken in VS 2019 preview 2 (Core 3.0 preview 1)

  • A+
Category:Languages

After installing VS 2019 preview 2 i get a great number of errors. Error demo code:

public class Class1 {     public static async IAsyncEnumerable<int> Get()     {         for( int i = 0; i < 10; i++ ) {             await Task.Delay( 100 );             yield return i;         }     } } 

and nothig more (a new dll project)!
With preview 1 was ok.

The project:

<Project Sdk="Microsoft.NET.Sdk">   <PropertyGroup>     <TargetFramework>netcoreapp3.0</TargetFramework>     <LangVersion>8.0</LangVersion>   </PropertyGroup> </Project> 

The error message is: Error CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator'

Object Browser shows the member in Collections.Generic.

Any ideas? Waiting for Core 3.0 preview 2?

Something like in IAsyncEnumerable not working in C# 8.0 preview ?

Another problem with VS 2019 P2 (another project): Nullabilty warnings though NullableReferenceTypes line is there (in vs 19, preview 1 was ok):

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">   <PropertyGroup>     <TargetFramework>netcoreapp3.0</TargetFramework>     <LangVersion>8.0</LangVersion>     **<NullableReferenceTypes>true</NullableReferenceTypes>** 

The warning:
Warning CS8632 The annotation for nullable reference types should only be used in code within a '#nullable' context.
Is project setting not enough? not global any more?

 


Problem 1

Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator'

Solution

Install .NET Core v3.0.100-preview-010177

https://github.com/dotnet/core-sdk#installers-and-binaries

Explanation

There was a breaking change to IAsyncEnumerable from .NET Core 3 Preview 1 to .NET Core Preview 2

Async streams

We changed the shape of the IAsyncEnumerable interface the compiler expects! This brings the compiler out of sync with the interface provided in .NET Core 3.0 Preview 1, which can cause you some amount of trouble. However, .NET Core 3.0 Preview 2 is due out shortly, and that brings the interfaces back in sync.

Source: https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-with-patterns-in-c-8-0/

Problem 2

The annotation for nullable reference types should only be used in code within a '#nullable' context

Solution

Change<NullableReferenceTypes>true</NullableReferenceTypes>

to

<NullableContextOptions>enable</NullableContextOptions>

Explanation

This is a breaking change from VS2019 Preview 1 to VS2019 Preview 2.

Nullable reference types

We’ve added more options to control nullable warnings both in source (through #nullable and #pragma warning directives) and at the project level. We also changed the project file opt-in to enable.

Source: https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-with-patterns-in-c-8-0/

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: