开发者

Re-organize namespaces according to directory structure

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.


Resharper can do this, though it's commercial. But there is a trial version.


Resharper > Right click on the project > Refactor Menu > Adjust Namespaces. This will re-arrange all namespaces according to folder structure, as it should be.


Resharper can do this as well as update the using statements in all files which use those classes.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜