JetBrains Rider 2026.1 Help

Code inspection: Async iterator invocation without 'await foreach'

This inspection reports a call to an async iterator whose result is ignored. Calling an async iterator method does not execute it in the way many developers expect. To consume it, the result must be iterated, usually with await foreach.

Example

using System.Collections.Generic; class C { public void Print() { ProduceAsync(); } public async IAsyncEnumerable<int> ProduceAsync() { yield return 42; } }
using System.Collections.Generic; using System.Threading.Tasks; class C { public async Task Print() { await foreach (var item in ProduceAsync()) item; } public async IAsyncEnumerable<int> ProduceAsync() { yield return 42; } }

Quick-fix

The quick-fix can rewrite the call into await foreach and make the containing method async if needed. After that, the iterator is actually consumed.

01 April 2026