Skip to content

Restore feature to tell people when a lambda is unnecessary.#58875

Merged
CyrusNajmabadi merged 38 commits intodotnet:mainfrom
CyrusNajmabadi:simplifyLambda
Jan 18, 2022
Merged

Restore feature to tell people when a lambda is unnecessary.#58875
CyrusNajmabadi merged 38 commits intodotnet:mainfrom
CyrusNajmabadi:simplifyLambda

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Jan 15, 2022

Fixes #40364

Looks like this:

image

Note the faded sections in the lambda. Invoking the fix gives you:

image

We used to have this feature, but had to disable it because this 'fix' could make performance worse due to the compiler no longer caching this delegate in the case of some static call. However, now that #58288 has gone in, the compiler will still cache these method group conversions if you are on C#11 or above.

This allows us to reenable the feature.

--

Note: this feature can be entirely disabled by suppressing this diagnostic ID. in that case no messages or fading will occur :)

todo:

  • Gui option to turn this off.

Relates to test plan #52192

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 15, 2022 04:55
@ghost ghost added the Area-IDE label Jan 15, 2022
CyrusNajmabadi and others added 4 commits January 14, 2022 20:03
…/CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs

Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
CyrusNajmabadi and others added 5 commits January 17, 2022 18:03
…on/CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs

Co-authored-by: David Wengier <david.wengier@microsoft.com>
@CyrusNajmabadi CyrusNajmabadi merged commit 33ff264 into dotnet:main Jan 18, 2022
@ghost ghost added this to the Next milestone Jan 18, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the simplifyLambda branch January 18, 2022 06:30
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P1 Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion to simplify lambda and delegate syntax

7 participants