Analyzer proposal: mark anonymous functions as static #52840
Labels
Area-Analyzers
Area-IDE
Feature Request
help wanted
The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Cause
An anonymous function that does not capture state from the enclosing scope is not marked as
static
.Rule description
Lambdas and anonymous methods can be marked with the
static
modifier, to disallow capture of locals or instance state. Adding thestatic
modifier to an anonymous function does not change the meaning of the program.By applying this code fix, it can be ensured that future modifications to a program do not result in unexpected retention of captured objects or unexpected additional allocations.
Additional context
The text was updated successfully, but these errors were encountered: