-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analyzer proposal: mark anonymous functions as static #52840
Comments
We explicitly decided not to do this as it would clutter up code that is intended to be terse unilaterally. |
@NTaylorMullen based on the design meeting notes, wouldn't it be better to offer it as a refactoring then? |
I'm not really a fan of refactorings taht do nothing but add a keyword to something. It can just be done manually with very little effort. |
Closing out as not planned. |
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: