-
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
Use static lambdas to better express intent concisely #47468
Conversation
@@ -64,10 +64,9 @@ public Accessor(SQLitePersistentStorage storage) | |||
|
|||
[PerformanceSensitive("https://github.com/dotnet/roslyn/issues/36114", AllowCaptures = false)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nifty if something validated this automatically. for now though, we have the attribute declaring intent, and we can ensure it is followed by use of static
lambdas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the plan for PerfSensitiveAnalyzer, we just never get time to work on that
Hello @CyrusNajmabadi! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-approval
These are a couple of areas where we switched, in the past, from a normal lambda to a static delegate to ensure we didn't accidentally capture something. The original changes were done because the captures ended up causing perf issues, and we wanted to make sure we didn't accidentally regress this.
We can now state this simply in the source by explicitly using a static-lambda. These lambdas now convey explicitly that they shoudl not capture, and it's no longer possible to accidentally cause them to do so (without a very obvious textual change on the declaration).