简体   繁体   中英

ReSharper: Rename namespace not available?

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

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

在此输入图像描述

NOT this

在此输入图像描述

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.

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM