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 Usings: for Project and Solution #56409

Open
TonyValenti opened this issue Sep 15, 2021 · 5 comments
Open

Add Usings: for Project and Solution #56409

TonyValenti opened this issue Sep 15, 2021 · 5 comments
Labels
Area-IDE Feature Request Need Design Review The end user experience design needs to be reviewed and approved.
Milestone

Comments

@TonyValenti
Copy link

Brief description:
Currently, if you're using classes that exist in a namespace like System.Linq but you forgot to add the import, you can right-click and use the "using System.Linq;" codefix. This is great but it can only be run on one file at a time.

Please enable this codefix to run on the entire project or hte entire solution. When it runs, it should fix all the files that have the exact same type or namespace that is missing. For example, if I am missing a using to System and I run the code-fix on a line that shows the error:
```The type or namespace name 'DateTime' could not be found (are you missing a using directive or an assembly reference?)````

It should add using System; to any place a DateTime is causing that error but not to places where another class might be.

Languages applicable:
C#

Documentation requirements:

When this analyzer is implemented, it must be documented by following the steps at Documentation for IDE CodeStyle analyzers.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Sep 15, 2021
@jinujoseph jinujoseph added Need Design Review The end user experience design needs to be reviewed and approved. and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 15, 2021
@jinujoseph jinujoseph added this to the Backlog milestone Sep 15, 2021
@jinujoseph jinujoseph added this to In Queue in IDE: Design review via automation Sep 15, 2021
@jmarolf
Copy link
Contributor

jmarolf commented Sep 15, 2021

I would propose that instead we just offer to add it as a global using

@CyrusNajmabadi
Copy link
Member

I'm a bit uncertain about how one gets into the use case that they have lots of code, all of which references a type which isn't available.

@LWChris
Copy link

LWChris commented Sep 15, 2021

I'm wondering the same as @CyrusNajmabadi.

Only thing I can think of: if you move one of your own classes, and then adjust the namespace accordingly. Now all other files referencing that class should need the new import (and probably remove the old import). Removing the old import can be done by code cleanup, but adding a new import is not a thing AFAIK.

@TonyValenti
Copy link
Author

@CyrusNajmabadi - I was using the "implicit using" feature from RC7 and I did the refactoring to remove unnecessary using. Then I decided I didn't want that feature and have to go through a ton of files and add the usings back in.

@LWChris
Copy link

LWChris commented Sep 17, 2021

@TonyValenti Oh that's unfortunate. Usually this is something a VCS would deal with though. You'd have one commit where you enabled that feature, and you can revert that commit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request Need Design Review The end user experience design needs to be reviewed and approved.
Projects
Status: In Queue
IDE: Design review
  
In Queue
Development

No branches or pull requests

5 participants