dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.9k stars 4.01k forks source link

Peek Implementation for interfaces #63074

Open vsfeedback opened 2 years ago

vsfeedback commented 2 years ago

This issue has been moved from a ticket on Developer Community.


Modern C# development now involves having interfaces for any class that might require one. At present, the only way to navigate to an implementation of this interface is to go directly to the file in a new tab. This results in many tabs opened and causes delay in learning / identification of the actual source code. We need a Peek to Implementation feature similar to Peek to Definition that is already available. This will improve the workflow of many developers using VS2022 as their daily driver.

One challenge I see what might hinder this feature is what if there are more than one implementation of the feature? In this scenario, instead of peeking we can directly open the window where it lists all the similar implementations. i.e., only peek when there is a direct match.

Its 2022 already and interface is the norm in any .NET development. I would be very helpful for the dev community to see this feature in action sooner than later.


Original Comments

Feedback Bot on 7/20/2022, 00:01 AM:

(private comment, text removed)

mikadumont commented 2 years ago

@jasonmalinowski I assume this would potentially be too busy in the right-click menu. Curious if we think Inheritance Margin should fix this? Or potentially offer Peek on Inheritance Margin?

CyrusNajmabadi commented 2 years ago

This results in many tabs opened and causes delay in learning / identification of the actual source code.

I'm not certain this is true. The tabs should be provisional. So there should only be one of them as you goto-impl on these types. If we're not using provisional tabs for that, we should be.

jasonmalinowski commented 2 years ago

The tabs should be provisional. So there should only be one of them as you goto-impl on these types. If we're not using provisional tabs for that, we should be.

It looks like we're using a provisional tab if there's only a single implementation. It looks like if you double click on the entries for multiple implementations it doesn't use a provisional tab -- single clicking does. It's possible that behavior is throwing this user off because they didn't expect that. Honestly, I didn't expect that either -- I'm too used to double-clicking from the error list being the navigation gesture I guess?

That all said, I can imagine the user might still find provisional tabs too intrustive and they like peek. Some users do. I think we've had other requests for peek implementation and it wouldn't be hard to do, other than I think the editor has to define the command.

davidwengier commented 2 years ago

if you double click on the entries for multiple implementations it doesn't use a provisional tab -- single clicking does

I remember from implementing project file editing, but this is standard provisional tab behaviour, FYI. eg, single click on a file in solutuon explorer, it will open provisionally, double click it will open for real.

ultrabstrong commented 12 months ago

@jasonmalinowski @davidwengier @mikadumont I agree that this should be available. I would anticipate it being bound to ctrl+alt+f12 (i.e. combining the 'peek' and 'go to implementation' hotkeys). There is already a mechanism for peeking with multiple results. I imagine something similar would be used for peeking with multiple implementations.

At the very least, when I use ctrl+f12 in the Peek Definition window I would like to see the implementation tab show up in the breadcrumb trail of the Peek Definition window rather than promoting the definition window to a regular document tab

I agree with the OP that this feature is necessary given modern programming practices.