vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

[BUG] Can't extract interface

Open arunchndr opened this issue 2 years ago • 11 comments

From vscode-dotnettools created by julioct: microsoft/vscode-dotnettools#545

Describe the Issue

Extracting an interface is an essential part of day-to-day coding activities, but with the latest C# extension version you can't do it.

In version 1.26.0:

image

In latest version:

image

Can we get the Extract interface... context menu item back?

Steps To Reproduce

  1. Use the lightbulb to open the context menu item on any class
  2. The extract interface... context menu item is not there

Expected Behavior

The extract interface... context menu item should be there.

Environment Information

  • OS: Windows 11
  • VS Code version: Code - Insiders 1.83.0-insider
  • Extension version: 2.2.10

arunchndr avatar Sep 25 '23 18:09 arunchndr

O# feature gap fill.

arunchndr avatar Sep 25 '23 18:09 arunchndr

Temp workaround:

Open workspace settings (json) Add:

{
  "dotnet.server.useOmnisharp": true,
...
}

m-abs avatar Oct 24 '23 10:10 m-abs

When is this feature going to be implemented? It's a very important one, in my opinion. I think VSCode is very close to replacing Visual Studio for Small to medium projects

vadimkholodilo avatar Nov 28 '23 02:11 vadimkholodilo

Temp workaround:

Open workspace settings (json) Add:

{
  "dotnet.server.useOmnisharp": true,
...
}

That doesn't help with C# Dev Kit installed, which most people would want to use:

image

This is so basic. Any updates on proper support?

julioct avatar Dec 26 '23 17:12 julioct

I have "C#" (Microsoft) and "C# Extensions" (JosKreativ) extension installed but not "C# Dev Kit" and it still doesn't work with Omnisharp :/

Edit: Right click on class name, choose "Refactor" (Ctrl+Shift+R), choose "Extract Interface...". Worked for me, but only with Omnisharp option ON.

mathmul avatar Jan 19 '24 11:01 mathmul

Months go by with this issue persisting. It actually hinders productivity by quite a lot having to manually implement interfaces and abstract classes. Disabling C# DevKit and enabling OmniSharp does resolve the issue but the extension itself along with other useful dependencies help with development.

Any updates or progress on this?

byakkodev avatar Mar 11 '24 18:03 byakkodev

I took a closer look at this feature. From O#, it looks like,

  1. It simply gets all the code action providers from Roslyn
  2. For extract interface, it creates many wrapper types in the code path when code action is invoked I. https://github.com/dotnet/roslyn/blob/main/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractInterface/OmniSharpExtractInterfaceOptionsService.cs II. https://github.com/OmniSharp/omnisharp-roslyn/blob/ac7b9b8509356e39583de2b9fdf363005e6c8595/src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceService.cs#L19 In simply words, it extracts all the extractable symbol in the type to a new interface. (In VS, we create UI to let user make choice)

If we want to close the gap between O#, it's easy to just create similar types in our LSP layers. But it's hard to create a similar thing in VS, because we don't control any UI in VSCode.

Cosifne avatar Mar 12 '24 20:03 Cosifne

Any updates or progress on this?

BrachaG avatar Mar 21 '24 12:03 BrachaG