Since capture lists are rejected as a language feature I think the next logical step is an IDE feature.
This is a great idea. Paging @jcouv as he seems to love exposing compiler innards in the IDE.
I love the idea.
@CyrusNajmabadi I don't know how to do those kinds of popups yet. Do you think this would be an extension of QuickInfo, or a new kind of popup?
Note to self: something like this.
It would be an extension of quickinfo. Basically, i think you'd want to modify "ISymbolDisplayService" to support adding this information for the symbol display for a local function or lambda.
Note: this should be easy for local functions, but a little more work will need to be done for lambdas. that's because AbstractSemanticQuickInfoProvider.BindTokenAsync probably doesn't even work on a => for a lambda. We'd need to make that work (as well as work for sub/function lambdas in VB).
Nothing about this is very hard. But it just means touching up a few places.
It would nice if we give visual clue if a local function/lambda is capturing anything at all. Heap allocation viewer extension underlines function name/lambda arrow if there is a closure which is really useful to spot non-capturing anonymous methods.
Further, this could go hand in hand with https://github.com/dotnet/roslyn/issues/3976 if we also make capture variables distinguishable with a different coloring (bringing this up since it's been three years and it's still open..)
I would add that request to #3976. Thanks!
I have a PR in progress (https://github.com/dotnet/roslyn/pull/23970) to list captured variables in QuickInfo.
@kuhlenh can we get a design meeting in January for Quick Info extensions?
Pushed this to 15.7 because underlying compiler API doesn't exist in 15.6 (we just added it to our 15.7 branch, features/compiler).
Feature is merged. Targeting 15.7.
Most helpful comment
I have a PR in progress (https://github.com/dotnet/roslyn/pull/23970) to list captured variables in QuickInfo.