9

I'm trying to rename a namespace. For some reason, ReSharper isn't giving me the option to do so. I right click on it and choose Refactor, but everything except "Convert" is greyed out. I try the key combination CTRL R + R, and it says the command is unavailable. What am I doing wrong?

Here is documentation suggesting that what I am trying to do should work:

http://www.jetbrains.com/resharper/documentation/help20/Refactoring/renaming.html#renameNamespace

I'm using Visual Studio 2008 with R# 4.5

Nick Heiner
  • 119,074
  • 188
  • 476
  • 699

4 Answers4

3

I have come across this before and the answer is very subtle. Do not select (eg by double clicking) the entire method name(or namespace if renaming a namespace). Instead, ensure the method name is deselected and place the caret over the method name. eg

enter image description here

NOT this

enter image description here

When you select the Convert menu the items should now be available for methods, and 'Rename' will become available if you had the caret over a namespace. In my mind this should be changed, it is not obvious.

Community
  • 1
  • 1
wal
  • 17,409
  • 8
  • 74
  • 109
  • Does not help me, also when I press Ctrl + R, Ctrl + R it selects the entire property name, which is exactly what you said I should not do... – MrFox Jul 19 '13 at 08:40
  • its `Ctrl+R, R` by the way. I'm using R# 8.0 and it now works if selected or not. what resharper version ru using? – wal Jul 19 '13 at 13:18
2

For what it's worth, I just had this problem. Closing Visual Studio and re-opening it fixed the problem for me. HTH.

Charlie Flowers
  • 17,338
  • 10
  • 71
  • 88
2

Apparently, the way to do this now is via ReSharper => Refactor => Adjust Namespaces menu or open the Class View, right click on the namespace you wanted to rename and again select Refactor => Adjust Namespaces.

See also: Fastest way to update namespaces with ReSharper?

Community
  • 1
  • 1
Michael Teper
  • 4,591
  • 2
  • 32
  • 49
0

This is an old issue but I just had this and perhaps know a workaround. Since someone has commented just yesterday timing could not be more perfect. Anyways, I had the same issue and was finally able to do a rename refactoring on my namespace.

  • I chose one of the classes in my project and did the move to another namespace refactor.
  • Then I was able to go to another class and do the rename namespace refactor.

Perhaps a bug in Resharper that if the namespace is consistent throughout the class then it's disabled? Unlikely since this was reported as far back as 4.5...

sjeffrey
  • 98
  • 1
  • 5