ReSharper 2026.1 Help

コードインスペクション:「EnumeratorCancellation」属性は、「IAsyncEnumerable<>」を返す Async イテレーター メソッドの「CancellationToken」型パラメーターでのみ有効です。

このインスペクションは、効果のない場所で [EnumeratorCancellation] が使用されていることを報告します。 この属性は、 IAsyncEnumerable<T> を返す非同期イテレータメソッドの CancellationToken パラメーターに対してのみ意味を持ちます。 他のパラメーター型やメソッド形状では、何も起こりません。

サンプル

using System.Collections.Generic; using System.Runtime.CompilerServices; class C { public async IAsyncEnumerable<int> M([EnumeratorCancellation] int token) { yield return token; } }
using System.Collections.Generic; class C { public async IAsyncEnumerable<int> M(int token) { yield return token; } }

クイックフィックス

応急処置では、効果のない属性を削除します。 もう 1 つの有効な手動修正方法は、 IAsyncEnumerable<T> を返す非同期イテレータの CancellationToken パラメーターに属性が適用されるようにメソッドを変更することです。

2026 年 6 月 12 日