描述
Version Used: 3.0.19.12206 (ec366687)
Steps to Reproduce: Compile the following code:
using System.Collections.Generic;
using System.Threading.Tasks;
class C
{
async IAsyncEnumerable<int> ProduceAsync()
{
await Task.CompletedTask;
yield return 42;
}
void Consume()
{
ProduceAsync(); // currently emits WRN_UnobservedAwaitableExpression
}
}
Expected Behavior:
Emit new warning with text like "Because result of asynchronous iterator call is not being iterated, execution of the current method continues before the call is completed. Consider using the 'await foreach' over the result of the call." For async-iterators returning IAsyncEnumerator<T> the second sentence may be omitted. Or maybe you'll come up with better wording which will work for both cases :)
Actual Behavior:
The warning "CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call" is emitted. But it's somewhat misleading.