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

Add option to to address all "Unnecessary using directive" #1179

Closed
jchannon opened this issue Feb 3, 2017 · 14 comments
Closed

Add option to to address all "Unnecessary using directive" #1179

jchannon opened this issue Feb 3, 2017 · 14 comments

Comments

@jchannon
Copy link
Contributor

jchannon commented Feb 3, 2017

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc4-004706)

Product Information:
 Version:            1.0.0-rc4-004706
 Commit SHA-1 hash:  e38bc4950c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.0-rc4-004706


VS Code version: 1.9.0
C# Extension version: 1.7.0-beta3

Steps to reproduce

Open a project, open the Problems pane. Get numerous information points about Unnecessary using directive.

Expected behavior

Could there be an option to globally address all these where it loops through those lines and removes the unnecessary usings?

Actual behavior

Nothing, just information/warnings

@DustinCampbell
Copy link
Member

I don't think we'll add a specific command for this. In VS Code, we'll to have the ability to provide "Fix All in {scope}" like we have in Visual Studio:

image

Now, eventually we might just have a general "clean up" command, but that's definitely different than a specific command only for remove unnecessary usings.

@jchannon
Copy link
Contributor Author

jchannon commented Feb 3, 2017 via email

@steve-lillis-cko
Copy link

@DustinCampbell Before I go ahead and raise a separate issue for this, can you confirm if unnecessary usings should be highlighted in some way? If not, is there a specific motivation as to why? Currently I'm having to select each using until I find one that isn't needed so I can use "Remove Unnecessary Usings" to clear them all

@DustinCampbell
Copy link
Member

@steve-lillis-cko: Follow the discussion on #1429 for the details. We've added an option in the latest beta of C# for Visual Studio to make hidden diagnostics appear in the editor and Problems tab.

@kleber-swf
Copy link

kleber-swf commented Dec 21, 2017

A command for a remove usings would be nice for cases like that:

image

In this case I'm opening file by file and removing each unused using.

@jools-adams
Copy link

It would be great to have unnecessary using's to be highlighted (or greyed out, as per VS for Mac) in VS Code.

@DustinCampbell
Copy link
Member

@jools-adams: Agreed. I'm tracking microsoft/vscode#20219 to get API support for VS Code so we can do exactly that.

@andrewbusch7
Copy link

@DustinCampbell did a separate issue get created for including removal of unused usings in a general cleanup command? As it stands, I need to jump back to VS2017 to efficiently clean up usings.

@0xdeafcafe
Copy link

Hey @DustinCampbell - that language feature is ready now. Is there an ETA on using it?

@rszemplinski
Copy link

Would love to see this feature added to VSCode.

@larryPlayabl
Copy link

Would love to see this added!

@andrewbusch7
Copy link

I've become quite accustomed to ctr+r,g for C# in VS2017, and using shift+alt+o/f10 for TS in vscode. Is it an option for the omnisharp extension to provide an implementation of editor.action.organiseImports for C#? Seems to be logical & consistent to me, and the fastest way for me to keep my code clean.

@jools-adams
Copy link

jools-adams commented Nov 2, 2018 via email

@CrossBound
Copy link

Any update on this? I would really love to have this available... It is so nice in VS to be able to run a keystroke and it remove & sort my usings.

I would say removing is more important than sorting to me but having both is having the cake and eating it too.

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

10 participants