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

后端 未结 2 1551
轻奢々
轻奢々 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:36

    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

    0 讨论(0)
  • 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) { } } }
    
    0 讨论(0)
提交回复
热议问题