Skip to content
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

Feature Request: add command for "remove unnecessary usings" #3236

Closed
reimer-atb opened this issue Aug 17, 2019 · 4 comments
Closed

Feature Request: add command for "remove unnecessary usings" #3236

reimer-atb opened this issue Aug 17, 2019 · 4 comments

Comments

@reimer-atb
Copy link

Issue Description

Steps to Reproduce

  1. Create a C# class in VSCode
  2. Add some using statements, which are not used in the code

Expected Behavior

There should be a command to trigger "remove unnecessary usings" from the command palette, like "organize imports" command for typescript files.

There should also be a way to apply this to all C# files in a folder / project.

Ideally, there would be an option in the settings to have "remove unnecessary usings" run automatically when saving a C# fle.

Actual Behavior

Unused using statements are greyed out but cannot be removed from any location in the file.
I have to scroll up to the top of the file, position the cursor on one of the unused using statements, press Command+. (on a Mac) and select "remove unnecessary usings".

This is ridiculous because most of the time, the using statements are not even visible on screen when working on the code further down the file.

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.37.1
C# Extension: 1.21.0

Mono Information OmniSharp using global mono :6.0.0
Dotnet Information .NET Core SDK (gemäß "global.json"): Version: 2.2.401 Commit: 729b316c13

Laufzeitumgebung:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.401/

Host (useful for support):
Version: 2.2.6
Commit: 7dac9b1b51

.NET Core SDKs installed:
2.2.401 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
angular-console nrwl 8.0.10
csharp ms-vscode 1.21.0
debugger-for-chrome msjsdiag 4.11.7
EditorConfig EditorConfig 0.13.0
Go ms-vscode 0.11.4
java redhat 0.47.0
latex-workshop James-Yu 7.3.0
markdown-all-in-one yzhang 2.4.2
ng-template Angular 0.802.2
vscode-boot-dev-pack Pivotal 0.0.8
vscode-concourse Pivotal 1.10.0
vscode-docker ms-azuretools 0.7.0
vscode-java-debug vscjava 0.20.0
vscode-java-dependency vscjava 0.5.1
vscode-java-pack vscjava 0.7.1
vscode-java-test vscjava 0.19.0
vscode-kubernetes-tools ms-kubernetes-tools 1.0.2
vscode-manifest-yaml Pivotal 1.10.0
vscode-markdownlint DavidAnson 0.30.1
vscode-maven vscjava 0.18.1
vscode-spring-boot Pivotal 1.10.0
vscode-spring-boot-dashboard vscjava 0.1.6
vscode-spring-initializr vscjava 0.4.6
vscode-typescript-tslint-plugin ms-vscode 1.2.2
vscode-xml redhat 0.8.0
vscode-yaml redhat 0.4.1
vscodeintellicode VisualStudioExptTeam 1.1.9
@rchande
Copy link

rchande commented Aug 23, 2019

I think this is a duplicate of #1179

@rchande rchande closed this as completed Aug 23, 2019
@reimer-atb
Copy link
Author

@rchande there may be some overlap with #1179 but I was also asking/hoping for a command from command palette to trigger "remove unnecessary usings", as well as a preference setting to automatically trigger "remove unnecessary usings" when saving a file.

Also, from reading the comments I could not find the reason why #1179 was closed? The requested feature is not available (at least I haven't found it) but I also did not find any comment saying something like "we can't or won't implement that".

@mgsaraujo
Copy link

This feature would be so nice. 😢

@filipw
Copy link
Contributor

filipw commented Feb 14, 2021

#1245 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants