How to batch rename the namespace of an assembly during refactoring

Source: Internet
Author: User

Reconstruction is often required.CodeIf you just modify the namespace of a class, this operation is very simple. However, if a solution contains more than 20 projects and each project contains more than 100 class files, you need to modify a word or phrase in the namespace in a unified manner. How can this problem be solved?

To quickly implement this function, you must rely on third-party plug-ins. I recommend using resharper as a refactoring tool:

Now the latest version of resharper is 5.0. After installing Reshaper, restart Visual Studio, open the solution to be restructured, and select a class whose namespace is netcms. xxx. Let's try to change it to goldsoft. XX: select the netcms of namespace first. global, right-click, and the refactor option is unavailable in the pop-up window.

Tragedy ...... What should I do? You can query the resharper official website to know that this plug-in can rename the namespace, but the help document is very simple and does not explain how to deal with it. You can only find a solution by yourself. Open the Class View Interface of Visual Studio and you can see the namespace of the code used in each project.

Right-click the namespace we want to rename, perfect! Now the rename option is available.

Click the "RENAME" option, and a form is displayed for entering the new namespace. enter a new name and click "Next ".

Resharper starts to re-query the reference of the namespace in the entire project and automatically rename it. Note that this is what I got twice, so the project name is different.

After the name is successfully renamed, you can see that all the namespaces under the specified project have been modified.

The solution is re-generated one by one after modification. Generally, there is no problem. The task of renaming the namespace is completed.

P.s. Do not use this method to take open-source software as your own. The above operations are only for learning instructions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.