代码检查:冗余的 'WithCancellation()' 调用
如果在异步可枚举链中已应用相同的取消标记,则此检查会报告 .WithCancellation(...) 调用。 多余的调用是冗余的,并不会改变取消的行为。
示例
var items = source
.WithCancellation(token)
.ConfigureAwait(true)
.WithCancellation(token);
var items = source
.WithCancellation(token)
.ConfigureAwait(true);
快速修复
快速修复会移除冗余的 WithCancellation() 调用。
2026年 5月 8日