在Visual Studio中重命名整个命名空间 [英] Renaming the Whole Namespace in Visual Studio

查看:209
本文介绍了在Visual Studio中重命名整个命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个庞大的项目并且去改变了有效的命名空间,然后我重构了只适用于少数类文件的代码,所以现在我在某些文件中有不同的命名空间,而在其他文件中有原始的命名空间。该项目现在不会建立。我无法撤消,我需要一种方法来更改WHOLE命名空间(其中一些是一个命名空间,一些是不同的,我想将其更改为1,这是相同的),而不仅仅是像重构那样的符号之一。请帮助我,我在C#和Visual Studio 2010 Express编码,所以我不能使用resharper。谢谢你

I am working on a huge project and went to change the namespace which worked, then I refactored the code which worked for only a few class files so now I have different namespaces in some files and original namespaces in others. The project now will not build. I cannot undo and I need a way to change the WHOLE namespace (some of them are one namespace and some are a different one, both which i want to change to 1 which is the same) not just one of the symbols like refactoring does. Please help me I am coding in C# and Visual Studio 2010 Express so I can't use resharper. Thank You

推荐答案

你好,



你可能想要改变项目属性的默认命名空间已经这样做了,它将帮助新文件本身落入新的命名空间。你也许想修改你的汇编信息(正如我们的朋友在评论中提到的那样,这并不重要。我的理解是,如果你想重构你的代码,你也应该看看这里。)



至于你现有的文件,如果你没有使用重构,恐怕你可能需要手动更改命名空间(我的意思是使用重构引擎来改变名称,但作为朋友在评论中纠正了,我同意重构不只是改变名称。视觉工作室做得很好,你不需要重新锐化。)



是的你还可以工作使用代码位于不同命名空间的应用程序,因为命名空间用于更好的代码组织。



如果在更改名称空间后遇到问题构建解决方案,请重新检查您的项目是没有参考。当我不得不为多个项目的应用程序更改命名空间时,我遇到了类似的问题,我碰巧通过使用新命名空间修复引用来解决它。我使用了一个名为agent ransack的工具来查找和修复错误引用的问题。可能它会帮助你。
Hi,

You may want to change default namespace from project properties if you haven't already done that, it will help new files to fall under new namespace by itself. you may want to modify your assembly info as well there (as our friend has mentioned in comment, it's not important. my understanding is that if you are trying to refactor your code, you should look here as well).

As for your existing files, Am afraid you may have to change namespace manually if you are not using refactoring (well i meant using refactoring engine to change name, but as a friend rectified in comment, i do agree refactoring is not just changing name. and visual studio does a great job, you don't need re-sharper).

Yes you can still work with your application with code being in different namespaces, as namespace is for better code organization.

If you are having issues building solution after changing namespaces, recheck your project which is failing for references. i had similar issue when i had to change namespace for our application with multiple projects, i happened to resolve it by fixing references with new namespace. i used a tool called "agent ransack" to find and fix issues with false references. may be it will help you.


你不必使用Resharper。 Visual Studio附带的标准重构引擎完美地完成了这项工作。我不知道为什么你说像重构一样。它完全正确。



您绝对不需要更改任何程序集的默认命名空间。这只是项目设置之一,它不会影响应用程序行为。它只是影响Visual Studio的行为,只是一点:当你添加一个类(或任何其他自动生成的代码)时,代码是根据这个默认程序集编写的。如果您忘记修改此选项,则可以随时更改任何命名空间;你甚至可以忽略这个问题。



-SA
You don't have to use Resharper. Standard refactorication engine which comes with Visual Studio does this job perfectly. I have no idea why you say "like refactoring does". It does it all correctly.

And you absolutely don't need to change default namespace of any of the assembly. This is just one of the project settings, it does not affect application behavior whatsoever. It just affect the behavior of Visual Studio, just a bit: when you add a class (or any other auto-generated code), the code is written according to this default assembly. If you forgot to modify this option, you can change any namespace at any time; you can even ignore the problem.

—SA


这篇关于在Visual Studio中重命名整个命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆