-
Notifications
You must be signed in to change notification settings - Fork 4.2k
"Make method async" in iterator method should change return type to IAsyncEnumerable instead of Task #31841
Copy link
Copy link
Closed
Labels
Area-IDEBugFeature - Async StreamsAsync StreamsAsync StreamsResolution-FixedThe bug has been fixed and/or the requested behavior has been implementedThe bug has been fixed and/or the requested behavior has been implemented
Milestone
Description
using System.Collections.Generic;
using System.Threading.Tasks;
class C
{
IEnumerable<int> M()
{
await Task.Yield();
yield return 0;
}
}Expected result when using "Make method async" on await Task.Yield():
using System.Collections.Generic;
using System.Threading.Tasks;
class C
{
async IAsyncEnumerable<int> MAsync()
{
await Task.Yield();
yield return 0;
}
}Actual result:
using System.Collections.Generic;
using System.Threading.Tasks;
class C
{
async Task<IEnumerable<int>> MAsync() // CS1624: The body of 'C.MAsync()' cannot be an iterator block because 'Task<IEnumerable<int>>' is not an iterator interface type
{
await Task.Yield();
yield return 0;
}
}The question would be what to do if IAsyncEnumerable is not available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-IDEBugFeature - Async StreamsAsync StreamsAsync StreamsResolution-FixedThe bug has been fixed and/or the requested behavior has been implementedThe bug has been fixed and/or the requested behavior has been implemented
Type
Fields
Give feedbackNo fields configured for issues without a type.