ReSharper 2026.1 Help

代码检查:Lambda 表达式/匿名方法必须为 'static' 以避免分配。

该检查报告将无捕获的 Lambda 表达式传递到要求显式为 static 委托的地方,例如传递给带有 [RequireStaticDelegate] 标记的参数。

示例

void M([RequireStaticDelegate] Func<int, int> f) {} void Test() { M(x => x + 1); }
void M([RequireStaticDelegate] Func<int, int> f) {} void Test() { M(static x => x + 1); }

快速修复

为 lambda 表达式添加 static 修饰符。

2026年 5月 8日