How do I refactor the namespace of components that use dotted notation in my Visual Studio 2010 Pro
solutions (C#
)?
I have tried selecting Refactor->Rename
or pressing F2 with the cursor at the head of the namespace string, but this only works for the first part of a dotted namespace string (e.g. "a.b.c.d" selects "a").
I've also tried highlighting the entire namespace and selecting Refactor->Rename
but I'm presented with a dial开发者_StackOverflowog message that says: "Please select a symbol to be renamed.
"
Any help?
VS doesn't have anything built into it for this (yet).
ReSharper can do it for you:
For this i removed the .Entities
from the namespace (sorry, i had to disguise some namespaces there, but you get the idea).
If you don't want to download a trial version of ReSharper and do it (hey, you may end up liking it!), then your best option is to ensure you have all your projects loaded, change the namespace at the top of the relevant class files, then attempt a recompile. All the faulty declarations or namespce useage will now show up in the Error List window - except for some XAML ones. (Some XAML useages will show up straight away, others will only show up at run time. You should be able to do a global search + replace on .xaml files only, this is reasonably safe, but make sure you have your files either backed up or managed in a source control repository).
Wouldn't find/replace do this for you? Search for namespace a.b.c.d
, replace with namespace d.e.f
; find using a.b.c.d
, replace with using d.e.f
.
精彩评论