Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Clean Namespace
Clean Namespace

Clean Namespace

Michael Hanson

|
1,937 clicks
| (1) | Free
Visual Studio 2008 Addin to set the namespace of new C# classes to match the Default Namespace of the project, effectively removing the folder hierarchy that VS adds to classes in folders.
Get Started

One of my pet hates about Visual Studio is that it assumes that you organise folders in projects according to namespaces and adds folder names to the namespace declaration for classes.  Worse still there is no way to turn this behaviour off.

Usually I get round this by adding my classes to the root of the project then dragging them to the relevant folder, and I mandate that developers working for me do the same.  This week I came across a developer who complained about this and come up with reasons based around the lack of tool help if they forget, so I decided to write an addin that automagically sets the namespace declaration of new C# classes to match the Default Namespace setting in Project Properties.  I have called it Clean Namespace.

No commands, menus or UI it just detects when a new C# class file is added to your project and changes the namespace declaration.  You can turn it off simply by disabling the addin via Tools, Add-in Manager..

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft