How do I get the new async semantics working in VS2017 RC?

♀尐吖头ヾ 提交于 2019-11-30 08:56:06

There is nothing else you need to do to enable task-like returns. The issue here is that the diagonstic message for this feature hasn't been updated yet. Here is a link to the tracking issue:

https://github.com/dotnet/roslyn/issues/12621

The TasklikeAttribute attribute name turns out isn't what's implemented in VS2017 RC, that's from a different version of the proposal. What's actually implemented relies on a type System.Runtime.CompilerServices.AsyncMethodBuilderAttribute, which appears to work exactly the same way.

I was not able to find this documented, but I was able to find this in the Roslyn tests, for example CodeGenAsyncTests.cs:

[AsyncMethodBuilder(typeof(ValueTaskMethodBuilder))]
struct ValueTask { }
...
namespace System.Runtime.CompilerServices { class AsyncMethodBuilderAttribute : System.Attribute { public AsyncMethodBuilderAttribute(System.Type t) { } } }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!