[英]Removing part of a namespace across entire project
I know that I can rename a namespace using Visual Studio 2010, but I need to remove part of a namespace.我知道我可以使用 Visual Studio 2010 重命名命名空间,但我需要删除部分命名空间。
namespace Xyz.Common.Utils { ... }
Renamed to重命名为
namespace Common.Utils { ... }
I need to drop the Xyz part, but don't see a way to use the VS refactoring tool to do this.我需要删除 Xyz 部分,但看不到使用 VS 重构工具来执行此操作的方法。
This is what I did a few times and you don't need any third-party tool:这是我做了几次,你不需要任何第三方工具:
Refactor the name in to something unique like: fjhfhchdbyegdrkoksodbc
(if that's unique enough to you)将名称重构为独特的名称,例如: fjhfhchdbyegdrkoksodbc
(如果这对您来说足够独特)
Then do a global replace on fjhfhchdbyegdrkoksodbc.
然后对fjhfhchdbyegdrkoksodbc.
进行全局替换fjhfhchdbyegdrkoksodbc.
(including the dot) with an empty string. (包括点)与空字符串。
There's no way to do that in pure Visual Studio , although there's an option when you select a word with the right button, then Refactor »» Rename in VS2010, this option requires you to select a symbol.在纯Visual Studio 中没有办法做到这一点,尽管当你用右键选择一个单词时有一个选项,然后在 VS2010 中重构 »» 重命名,这个选项需要你选择一个符号。 In your case在你的情况下
namespace Xyz.Common.Utils { ... }
Xyz would be the symbol to refactor, but it cannot be renamed to an empty value . Xyz将是要重构的符号,但它不能重命名为空值。
Telerik JustCode can do the job instead: Telerik JustCode 可以代替完成这项工作:
http://www.telerik.com/products/justcode/features.aspx http://www.telerik.com/products/justcode/features.aspx
There's also a Trial Version.还有一个试用版。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.