-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull methodName Up refactoring no longer available since release 1.38.2 #2381
Comments
I will need to check this, however it was never intended to work in the first place. omnisharp-roslyn/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs Line 105 in 696cf21
omnisharp-roslyn/tests/OmniSharp.Roslyn.CSharp.Tests/CodeActionsWithOptionsFacts.cs Lines 194 to 210 in ff21ac4
It might have worked "by accident" and got removed with the recent changes to how we interact with Roslyn. |
I don't know who wrote the comment that this provides no additional value, but they could not be more wrong. If my class already implements an interface then extracting or generating a new one does nothing for me, I need to update the existing one. |
I also use to use this all the time and thought it was just a bug in my setup that it disappeared. I would like to echo @JeremyCaron 's point that it makes no sense to generate a whole new interface for a type that already has one. I realize if there are multiple levels of interfaces or multiple interfaces on the type it is harder to pick, but the vast common case (at least in my 12 years of C#) is a class with a single interface that we want to pull a method up to. |
Testing with C# 1.24.1 and 1.24.0, I was unable to get this refactoring be offered with the following test file and the cursor at various places on the namespace TestConsole
{
public interface IPerson
{
}
public class Person : IPerson
{
public void Run()
{
}
}
} After looking at the Roslyn code for pull member up, I am unsure how this would have ever worked. The RefactoringProvider and CodeAction require a workspace service that has no default implementation and has not had an implementation in O#. To support this feature, we would need to expose the internal The open questions are what to return since we have no UI. Would a member go to a base class over an interface when both are specified? If there are multiple interfaces implemented by the class, would it go to the first specified? etc... |
Thanks, I'll try rolling back too. I might have had the version numbers wrong though? filipw changed the title to say 1.38.2 on Apr 12, 2022 |
1.38.2 is the O# version used by C# ext 1.24.2 where you saw the issue. |
Issue Description
The "Pull
methodName
Up" refactoring is no longer available on methods. This is one of the refactorings I use the most and have had to revert to 1.24.1 to use it.Steps to Reproduce
Create an empty class that implements an empty interface. Add a method to the class and Ctrl-. to get the refactorings list. It should show "Pull
methodName
Up" but does not.Expected Behavior
"Pull
methodName
Up" refactoring option should be available in the list.Actual Behavior
Logs
OmniSharp log
OmniSharp server started with .NET 6.0.100
.
Path: c:\Users\Jeremy.vscode\extensions\ms-dotnettools.csharp-1.24.2-win32-x64.omnisharp\1.38.2-net6.0\OmniSharp.dll
PID: 6864
Starting OmniSharp on Windows 10.0.19043.0 (x64)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.100 17.0.0 - "C:\Program Files\dotnet\sdk\6.0.100"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.100 17.0.0 - "C:\Program Files\dotnet\sdk\6.0.100"
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.MSBuild.ProjectSystem
... loading lots of projects - snipped...
Received response for /quickinfo but could not find request.
C# log
Downloading package 'OmniSharp for Windows (.NET 6 / x64)' (39624 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Windows (.NET 6 / x64)'
Finished
Environment information
VSCode version: 1.66.1
C# Extension: 1.24.2
Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.100 Commit: 9e8b04bbffRuntime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
5.0.301 [C:\Program Files\dotnet\sdk]
6.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
The text was updated successfully, but these errors were encountered: