#1,213 – Visual Studio 2015 – Unused using Statements Greyed Out
October 28, 2014 8 Comments
In Visual Studio 2015, the editor will grey out any using statements that are not required. This is done at build time. Note that you can still use the Remove Unused Usings command to remove any unused statements. (This command has been renamed Remove Unnecessary Usings).
Below, all but the first using statement is greyed out, since the code that follows makes no use of types from any of the other namespaces.
Like ReSharper ))
Pingback: Dew Drop – October 28, 2014 (#1886) | Morning Dew
That’s handy! I used the Remove Unused Usings command a few times yesterday, and it got rid of all of the usings, haha…
Do you know if there’s a command to remove the usings across all of the project files? Would be easier than doing each one individually.
I don’t know if there’s a way to do this across multiple files.
You can use CodeMaid Visual Studio extension to do that. It has much more features along with removing all unused using from multiple files/entire project/solution.
https://visualstudiogallery.msdn.microsoft.com/76293c4d-8c16-4f4a-aee6-21f83a571496
This option is already in Resharper. Or you could build a macro http://stackoverflow.com/questions/283471/remove-unused-namespaces-across-a-whole-project-or-solution-at-once
Right–now that the option is baked into Visual Studio, it’s one less reason to need Resharper. Note that for many large production codebases, Resharper is unusable because it slows Visual Studio and the compile/run/debug loop down too much to be effective.
Hover over an unnecessary using directive (or type Ctrl+,) to display the Quick Actions SmartTip. From the SmartTip drop-down list, select Remove Unnecessary Usings. At the bottom of the details popup, select to fix all occurrences in the Document, Project, or Solution.