dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 653 forks source link

[BUG] Can't extract interface #6430

Open arkalyanms opened 9 months ago

arkalyanms commented 9 months ago

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

arkalyanms commented 9 months ago

O# feature gap fill.

m-abs commented 8 months ago

Temp workaround:

Open workspace settings (json) Add:

{
  "dotnet.server.useOmnisharp": true,
...
}
vadimkholodilo commented 7 months ago

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

julioct commented 6 months ago

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?

mathmul commented 5 months ago

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.

byakkodev commented 3 months ago

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?

Cosifne commented 3 months ago

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.

BrachaG commented 3 months ago

Any updates or progress on this?

sys58260 commented 1 month ago

Is it foreseen in near future? Thanks.

Thiago-Morais commented 1 month ago

Is there any update on this?