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.