#VisualStudio 2015 Tips - How to organize "usings" across solution?


Whenever you create a new code file in Visual Studio, it adds a default set of using namespaces automatically to faster the development process in common name resolution. Not all of them are mandatory to use and can be remove at later point of time or before code check-in.

 

Visual Studio 2015 provides us an easy way to organize the using namespaces within the active code file, project and/or solution. You will really love this new feature. Continue reading to learn more about it.

 

Visual Studio 2015 Tips & Tricks - How to organize "using namespaces" easily across project/solution? (www.kunal-chowdhury.com)

 

The old versions of Visual Studio already has the way to organize the using statements, but that is only applicable within the active code file. If you want to cleanup unnecessary namespace declaration, you had to manually open each files, right click on them and from the context menu you had to visit “Organize Usings” and then had to select the appropriate menu items in order to sort and remove unnecessary declarations.

 

Here you can find the screenshot of the same to visualize it:

 

Visual Studio Tips & Tricks - Old ways to organize using namespaces

 

 

Visual Studio 2015 also provides the same functionality. You can follow the same steps in order to remove the unused using namespaces from individual file. But as you know, the process is very lengthy when you want to do this for all the files available in a project or a solution.

 

The new feature allows you to easily remove the unnecessary using namespaces from individual file or files within a project/solution. You can also preview all the changes before actually committing it. To do this, open any code file and click the small bulb near to the using declarations as shown below:

 

Visual Studio 2015 Tips & Tricks - New way to remove unnecessary using namespaces

 

Inside the popup menu, you can find a panel with three different links named Document, Project and Solution. If you want to perform this operation within the same document, click “Document”; for project or solution click the respective link. Once clicked, Visual Studio 2015 will automatically start removing all unnecessary using namespaces from your code.

 

I hope, it was clear from the above post. Please let me know if you have any comments. Also, don’t forget to read my other posts on Visual Studio 2015 Tips & Tricks available in this web URL:  http://visual-studio-2015.kunal-chowdhury.com

 


If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Twitter, Facebook, Google+ and LinkedIn. I would love to hear your thoughts and opinions on my articles directly. Also, don't forget to share your views and/or feedback in the comment section below.

0 comments

 
© 2008-2016 Kunal-Chowdhury.com - Microsoft Technology Blog for developers and consumers | Designed by Kunal Chowdhury
Back to top