I have a solution with a few projects. Remove unnecessary usings
is working in all projects except for one.
Why does the Remove unnecessary usings
command not work in some projects?
Edit - As you can see in the Before image there is no Remove unnecessary usings
command and if you try to right-click in the file, then Organize usings > Remove unnecessary usings
does nothing. After setting the project build warning level to 4 the Remove unnecessary usings
command appears and works.
Before:
After:
First is putting your cursor on one of the grayed out lines and clicking the light bulb, then clicking Remove Unnecessary Usings. (NOTE: The shortcut key for this is CTRL-.) When the action is executed the references will be cleaned up.
Needing to set the Warning Level
to 4 for code analyzers to fire is a Roslyn known issue.
Additionally, check your projects' Code Analysis rules (project properties > Code Analysis > Open). We had CS8019 and IDE0005 disabled, which prevents the code fix from being offered and the unused using(s) from being highlighted, respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With