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

后端 未结 2 1572
轻奢々
轻奢々 2020-12-30 09:19

Quoting from Visual Studio 2017 RC Release Notes

Language Extensions and Analyzers

This release includes some proposed new langua

2条回答
  •  孤独总比滥情好
    2020-12-30 09:38

    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) { } } }
    

提交回复
热议问题