ReSharper 2026.1 Help

Code inspection: Lambda expression/anonymous method must be 'static' to avoid allocations

This inspection reports a capture-free lambda expression passed where the delegate is required to be explicitly static, for example to a parameter marked with [RequireStaticDelegate].

Example

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); }

Quick-fix

Add the static modifier to the lambda expression.

30 March 2026