使用 ReSharper 更新名称空间的最快方法?

我一直在做一些重构和重组,我已经移动了大量的文件。

我想更新每个文件,使其具有“正确的”名称空间根据其新的位置。使用 ReSharper,我可以进入每个文件,它向我显示名称空间是不正确的,但这样我必须一次处理每个文件。

是否存在跨文件夹或项目中的每个文件更新名称空间的方法?

18728 次浏览

I think that R# doesn't have this function. You can use CTRL-SHIFT-H to find&replace the string.

This isn't quite what you want to do ... but hopefully it's helpful.

Go to the class view, and rename the namespace using Ctrl+R,R. It will update that namespace in all the files/folders that it's used in. As long as your namespaces are consistant, it should acheive the same result as changing all the namespaces in a folder.

If your namespaces aren't consistant, and you're just tidying up then I'm afraid you've got a lot of clicking in front of you (or behind you as you've probably already done this).

UPDATE: Anyone reading this question with R#5.0 and above should note that this is now a feature:

ReSharper -> Refactor -> Adjust Namespaces...