What's the best way to do a bulk namespace rename on a large c# application?

后端 未结 7 1178
旧时难觅i
旧时难觅i 2020-12-15 15:41

First, a little background.

Currently namespaces and assemblies in our codebase (~60 assemblies, thousands of classes) looks like

WidgetCompany.Depar         


        
7条回答
  •  北海茫月
    2020-12-15 15:44

    Firstly I would try Refactor->Rename option. But as mentioned in comment for another answers it doesn't work that good (Or I haven't found how to make it working). So I prefer using following scenario, especially if you want to add some addiotional namespace.

    1) Rename your root namespace (WidgetCompany) to something like NAMESPACE_TO_BE_REPLACED using Refactor-Rename
    2) Replace NAMESPACE_TO_BE_REPLACED with your final namespace (NewCompany.WidgetSoftware) using find-n-replace dialog

    And do not forget to rename projects, default namespaces, etc.

提交回复
热议问题