« A Refactorability Approach to Software Reusability | Main | Additional Relational Metadata for artifacts in MOSS -- Part 2 »

Organizing Using Statements - New Feature in Visual Studio 2008

One cool new feature which might not be apparent to us unless and until we really go through all the new features that have been incorporated into the Visual Studio 2008 IDE is the feature which allows us to organize the Using statements that we always use in our source code files. This would be really useful as i have often seen that people use more Using statements than what is actually required, and we always have the habit of adding Using statements as and when required. But at the end of our development process, we would like to do a clean up and make sure that we have put Using statements only for the required namespaces and possibly make it more readable by sorting these statements alphabetically etc.

The Visual Studio 2008 IDE provides the following options to organize and remove usings/imports statements:

  • Remove Unused Usings
    Removes using directives, using aliases, and extern aliases that are not used in the source code.
  • Sort Usings
    Improves the readability of the source code by alphabetizing and organizing using directives, using aliases, and extern aliases in the following order:
    • extern aliases
    • using directives
    • using aliases
  • Remove and Sort
    Does both removal as well sorting discussed above.

Organize Usings

To see the available options in the Visual Studio IDE, on the Edit menu, point to IntelliSense, and then point to Organize Usings. An easier way to do this would be to Right-click anywhere inside the code editor, point to Organize Usings as shown in the figure above and click on any of the 3 options available.

For more information on this feature please read this msdn article.

A very small but useful feature indeed!

TrackBack

TrackBack URL for this entry:
http://www.infosysblogs.com/apps/mt-tb.cgi/1795

Comments

Apart from making the code prettier, does removing unused usings improve performance (at compile time or run time)?

Andy, unused using is something that the compiler would have removed anyway. This is more for making the code prettier, as you said !

Hi,

When I use the same, the Visual Studio crashes. Not sure why it is happening. Any insights on this would be appreciated.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter