Automatic removal of unnecessary namespace

  • Thread starter Thread starter Oscar Thornell
  • Start date Start date
O

Oscar Thornell

Hi,

I am looking for a feature/functionality in VS.NET 2005 that removes using
directives/includes of unnecessary namespaces.
IDEs like Eclipse and JBuilder have had stuff like that for years and my
guess is that VS.NET 2005 has it to...but where?

Regards
/Oscar
 
Hi Oscar,
I don't know of any tool that will do this but the C# compiler
automatically removes references to assemblies that are not referenced
anywhere in the code, so you don't need to worry about removing using
statements, it will not be any performance hit.

Mark Dawson
http://www.markdawson.org
 
Hi Oscar,
I don't know of any tool that will do this but the C# compiler
automatically removes references to assemblies that are not referenced
anywhere in the code, so you don't need to worry about removing using
statements, it will not be any performance hit.

Mark Dawson
http://www.markdawson.org

I like to keep my using block clean too. :)

Resharper does this with it's "Optimize usings" feature and much much more.
Although the VS 2005 version isn't ready yet, it's the single best productivity
tool for me in VS.NET 2003.

Chris
 
I like to keep my using block clean too. :)

Resharper does this with it's "Optimize usings" feature and much much more.
Although the VS 2005 version isn't ready yet, it's the single best productivity
tool for me in VS.NET 2003.

Chris
I use Poor Man's Resharper®. I comment out all the using directives
and add them back one at a time until it builds again. As you chug
along it whines about each missing one as it finds it. Remove the
comments, rebuild, remove the comments, ...

Another item we use to help developers is to use comments after the
using directive to specify why it's even there, especially if it is
less than obvious. Here's a really bad example:

using System.Windows.Forms; // OpenFileDialog

But you get the gist. This helps the original developer and the
future maintainers manage the project without having to rely on their
photographic memories (considering some done even have film for it.)
[8-) Anyway, in a standard Window's app that comment would be
redundant, or extremely long, so you wouldn't even bother. However,
that sample comes from a MS Word add-in so it automatically answers
the question why it's there.

Ken Wilson
Seeking viable employment in Victoria, BC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top