vscode-csharp
vscode-csharp copied to clipboard
[BUG] Can't extract interface
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:
In latest version:
Can we get the Extract interface... context menu item back?
Steps To Reproduce
- Use the lightbulb to open the context menu item on any class
- 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
O# feature gap fill.
Temp workaround:
Open workspace settings (json) Add:
{
"dotnet.server.useOmnisharp": true,
...
}
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
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:
This is so basic. Any updates on proper support?
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.
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?
I took a closer look at this feature. From O#, it looks like,
- It simply gets all the code action providers from Roslyn
- 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.
Any updates or progress on this?