me-*_*tov 5 c# c#-8.0 iasyncenumerable nullable-reference-types
安装VS 2019预览2后,我收到很多错误.错误演示代码:
public class Class1 {
public static async IAsyncEnumerable<int> Get()
{
for( int i = 0; i < 10; i++ ) {
await Task.Delay( 100 );
yield return i;
}
}
}
Run Code Online (Sandbox Code Playgroud)
而且还有更多(一个新的dll项目)!
预览1还可以.
该项目:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
错误消息是: 错误CS0656缺少编译器所需的成员'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator'
对象浏览器显示Collections.Generic中的成员.
有任何想法吗?等待Core 3.0预览版2?
IAsyncEnumerable中的某些东西在C#8.0预览版中不起作用 ?
VS 2019 P2的另一个问题(另一个项目):虽然NullableReferenceTypes行有Nullabilty警告(在vs 19中,预览1没问题):
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
**<NullableReferenceTypes>true</NullableReferenceTypes>**
Run Code Online (Sandbox Code Playgroud)
警告:
警告CS8632可以为空的引用类型的注释只应在'#nullable'上下文中的代码中使用.
项目设置不够吗?不再全球化?
缺少编译器需要成员'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator'
安装.NET Core v3.0.100-preview-010177
https://github.com/dotnet/core-sdk#installers-and-binaries
IAsyncEnumerable从.NET Core 3 Preview 1到.NET Core Preview 2 发生了重大变化
异步流
我们改变了编译器期望的IAsyncEnumerable接口的形状!这使编译器与.NET Core 3.0 Preview 1中提供的接口不同步,这可能会给您带来一些麻烦.但是,.NET Core 3.0 Preview 2即将发布,这将使接口重新同步.
资料来源:https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-with-patterns-in-c-8-0/
可以为空的引用类型的注释只应在'#nullable'上下文中的代码中使用
更改<NullableReferenceTypes>true</NullableReferenceTypes>
至
<NullableContextOptions>enable</NullableContextOptions>
这是从VS2019预览1到VS2019预览2的重大变化.
可空的引用类型
我们在源代码(通过#nullable和#pragma警告指令)和项目级别添加了更多选项来控制可空警告.我们还更改了项目文件opt-in以启用.
资料来源:https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-with-patterns-in-c-8-0/
| 归档时间: |
|
| 查看次数: |
1217 次 |
| 最近记录: |