david.s
david.s

Reputation: 11403

"Remove unnecessary usings" not working in Visual Studio 2015

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:

Before

After:

After

Upvotes: 9

Views: 3423

Answers (2)

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.

Upvotes: 9

david.s
david.s

Reputation: 11403

In the Build section of the project properties there is a setting called Errors and warnings which should be 4.

enter image description here

Upvotes: 14

Related Questions