ReSharper 2026.1 Help

代码检查:多余的 'WithCancellation()' 调用

当在异步可枚举链中已应用相同的取消令牌时,此检查会报告 .WithCancellation(...) 调用。 额外的调用是多余的,不会改变取消的行为。

示例

var items = source .WithCancellation(token) .ConfigureAwait(true) .WithCancellation(token);
var items = source .WithCancellation(token) .ConfigureAwait(true);

快速修复

快速修复将移除多余的 WithCancellation() 调用。

2026年 5月 8日