简体   繁体   English

在VS 2017中更改整个项目的命名空间

[英]Change namespace for entire project in VS 2017

Previously some of the classes were present in MyProject.Web.Core project, which are moved to MyProject.Model project. 以前有些类存在于MyProject.Web.Core项目中,它们被移动到MyProject.Model项目。 However these moved classes have namespace as MyProject.Web.Core . 但是,这些移动的类的名称空间为MyProject.Web.Core

So, how can I change the namespace for all classes to MyProject.Model as we don't want to update them manually. 那么,我怎样才能将所有类的命名空间更改为MyProject.Model因为我们不想手动更新它们。 Is there any option available in VS2017 ? VS2017有没有可用的选项?

We have already update the default namespace in project properties, so that will be get applied when new class is added. 我们已经更新了项目属性中的默认命名空间,因此在添加新类时将应用它。 But, how about for the moved/old classes? 但是,移动/旧课程怎么样?

Set your cursor into the namespace and then hit F2 to rename (if F2 didn't work, try CTRL R + CTRL R or rightclick - rename). 将光标设置为命名空间,然后按F2重命名(如果F2不起作用,请尝试按CTRL R + CTRL R或右键单击 - 重命名)。 All related namespaces should be changed. 应更改所有相关的命名空间。

This is a case where Jetbrains Resharper can help you. 这是Jetbrains Resharper可以帮助您的情况。 It identifies namespace mismatches and allows fixing it solution-wide. 它识别名称空间不匹配,并允许在解决方案范围内修复它。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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