Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to make use of 'using' directives in C# less tedious

Good programming practice these days tends to mean splitting your stuff up into lots of assemblies and namespaces (for example, see S#arp Architecture, MVC, etc.). However a side-effect of that is that you have to stick a whole bunch of 'using ' directives into every class file. You know the sort of thing: Every controller class needs to 'use' the models and viewmodels namespaces, etc., etc.

Are there any techniques for making this easier? For example, is it possible to declare using directives at the namespace level instead of the file level - so that every class in a namespace 'foo' automatically is using namespace 'bar'? Or are there smart ways of setting the default 'usings' that Visual Studio adds, based on the folder you are in? Or other ways of making the adding of 'usings' less tedious?

like image 516
codeulike Avatar asked Feb 15 '11 22:02

codeulike


1 Answers

To make the management of adding 'usings' and removing unnecessary 'usings' less tedious, I recommend trying out JetBrains' ReSharper. It will help recognize when you need to add a missing 'using' and will grey out 'using' statements that are not needed.

like image 58
Dave Brace Avatar answered Sep 20 '22 19:09

Dave Brace