重命名 .net 中的命名空间
我从事的项目有一个代号,它用于项目中各处的命名空间。
我怎样才能在不冒破损风险的情况下快速更换它?
My project I worked on had a codename and this was used for the namespace everywhere in the project.
How can I change it without risking breakage and quickly as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ReSharper 可以非常安全、快速地完成此类操作。虽然它是一个商业工具,但我强烈推荐它。
否则只需进行搜索即可替换整个解决方案。这也很快并且应该适用于命名空间的大多数用法。
ReSharper can do stuff like this pretty safe and fast. Though it is a commercial tool I can highly recommend it.
Otherwise just do a search & replace in the whole solution. This is also fast and should work for most usages of the namespace.
您可以选择在 Visual Studio 中使用正则表达式查找和替换。这将使您能够更密切地控制要查找和替换的内容(尤其是标记),例如:
查找
替换为:
将替换以下内容:
与:
您始终可以先进行备份(或者在出现问题时回滚)错误的)。只需确保使用“保持修改的文件打开”选项,以便您可以轻松检查更改!
You could choose to use a regex find and replace in Visual Studio. This would allow you to control much more closely what you want to find and replace (especially with tagging), for example:
Find
Replace with:
Would replace the following:
with:
You can always take a backup first (or roll back if something goes wrong). Just make sure you use the option "keep modified files open" so you can check the changes easily!