Fastest way to update namespaces with ReSharper?

C#Resharper

C# Problem Overview


I have been doing some refactoring and reorganization and I have moved a bunch of files around.

I want to update each file so it has the "correct" namespace according to its new location. With ReSharper, I can go into each file and it shows me that the namespaces is incorrect but that way I have to do it each file at a time.

Is there anyway to update namespaces across every file in a folder or a project?

C# Solutions


Solution 1 - C#

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

ReSharper -> Refactor -> Adjust Namespaces...

Solution 2 - C#

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).

Solution 3 - C#

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionleoraView Question on Stackoverflow
Solution 1 - C#Iain HolderView Answer on Stackoverflow
Solution 2 - C#Mark WorthView Answer on Stackoverflow
Solution 3 - C#emaView Answer on Stackoverflow