Reputation: 24063
I made arrangement in my solution. I made seperation of projects and reorder directories. Now my namespaces are messed up. Is there any tool that will arrange the namespaces according to the position of the file in the project?
For example, if a cs file is in Printers/Pdf directory under MyProj project, I would like the namespace of the classes in the file will be MyProj.Printers.Pdf.
EDIT: I am looking for free tool if possible.
Upvotes: 3
Views: 697
Reputation: 45243
Resharper is the best option and is well worth the money. If you have paid the costs for Visual Studio, a Resharper license cost will feel like pennies.
As for free options, I think a project wide, find & replace might be your best bet. You could find what the incorrect namespace is, then folder by folder find it and replace it with the correct one. If you just moved it to a different project, you could just search for...
namespace MyOldProject.
and replace it with...
namespace MyNewProject.
This is assuming you kept directory structures.
Upvotes: 0
Reputation: 5628
Resharper can do this as well as update the using statements in all files which use those classes.
Upvotes: 1
Reputation: 2415
Resharper can do this, though it's commercial. But there is a trial version.
Upvotes: 2
Reputation: 25732
Resharper > Right click on the project > Refactor Menu > Adjust Namespaces
. This will re-arrange all namespaces according to folder structure, as it should be.
Upvotes: 1