简体   繁体   中英

Visual Studio 2010 Rename Project and cause Namespacing to correspond

In Visual Studio 2010 I have an ASP.NET MVC 3 project called blahblah. As such, all the code within this project is namespaced as blahblah.Controllers, blahblah.Configuration etc.

I want to be able to rename the project to blahblah.Web. Now I know I can just right click on the project and go to rename, but if I do this, none of the namespacing matches anymore.

I would like some way to convert all namespacing so that it is relative to the new project name. blahblah.Web.Controllers, blahblah.Web.Configuration, etc.

Is there an easy way to do this?

Yes, use ReSharper's 'Refactor' menu and select 'Adjust Namespaces'. http://www.jetbrains.com/resharper/webhelp/Refactorings__Adjust_Namespaces.html

The easiest way is to use a Replace in Files or CTRL + SHIFT + H .

Search for the full previous namespace eg namespace blahblah.Web.Controllers and replace with the new namespace eg namespace blahblah.Web.Configuration .

Also, remember the change the default namespace in the project properties so that any new files get created in the correct namespace.

Without third party add-ons: Edit > Find and Replace > Replace in Files

Find what: namespace blahblah
Replace with: namespace blahblah.Web

Click on Replace All.

Using Find and Replace

Do a search for "using blahblah." and replace it with "using blahblah.Web."

Ignore the quotation marks there just to show the string to use. That should do it easily enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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