什么是做批量重命名的命名空间在一个大的C#应用​​程序的最佳方法是什么? [英] What's the best way to do a bulk namespace rename on a large c# application?

查看:340
本文介绍了什么是做批量重命名的命名空间在一个大的C#应用​​程序的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,一些背景知识。

目前命名空间,并在我们的codeBase的组件(​​〜60集,千类),看起来像

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

WidgetCompany.Department.Something

我们现在已经被剥离出来,使得我们销售的驱动WidgetCompany软件,所以我们倒要重命名的命名空间和放大器;组件

We have now been spun off such that we are selling the software that drives a WidgetCompany, so we 'd like to rename the namespaces & assemblies

NewCompany.Something

在正常情况下,我可能只是坚持与旧的命名空间,但问题是我们的客户不希望看到他们的竞争对手在应用程序中的任何地方的名字之一。在他们看到一个堆栈跟踪,装配性能等关的机会,就不应该出现。这并不意味着要隐藏我们的员工,或做任何事情险恶,我们只需要确保人们知道我们是一个独立的实体,独立管理,他们不需要担心数据被共享等。

Under normal circumstances I'd probably just stick with the old namespace, but the problem is our customers don't want to see the name of one of their competitors anywhere in the application. In the off chance that they see a stack trace, assembly properties etc, it shouldn't show up. It's not meant to hide our associates or do anything sinister, we just need to make sure that people know we are a separate entity, separate management, and they don't need to worry about data being shared etc.

现在的问题。什么是执行这一类型的所有包含重命名的最佳方式? 下面就需要修改:

Now the question. What is the best way to perform this type of all encompassing rename? The following would need to change:

  • 命名空间(几乎)每类 应用
  • 在其中引用旧名称的应用程序的每个使用语句
  • 文件夹结构,为每个项目
  • 在这要靠改变文件夹结构,项目之间的引用
  • 引用该更改的文件夹结构的.sln文件
  • 来的任何引用 这些类这是完全 合格的(应该是少之又少 之间)
  • 来的任何引用 类XML配置文件(配置 部分等)
  • 每一个组件的AssemblyInfo.cs文件
  • 的AssemblyName在每一个.csproj的文件
  • Namespace for (almost) every class in the application
  • Every using statement in the application which references the old names
  • Folder structure for each project
  • References between projects which rely on changed folder structure
  • .Sln files which reference the changed folder structure
  • Any references to those classes which are fully qualified (should be few and far between)
  • Any references to those classes in xml config files (config sections etc)
  • AssemblyInfo.cs files for every assembly
  • AssemblyName in every .csproj file

我是坚持与查找替换,祈祷策略或者是有什么好?

Am I stuck with the find-replace-pray strategy or is there something better?

推荐答案

右键单击您当前的命名空间,并选择重构 - >重命名和更改弹出了一段时间后出现的名字。输入您的新名称,然后点击确定。

Right click on your current namespace and select Refactor -> Rename and change the name in the pop up that comes up after a while. Enter your new name and click ok.

这篇关于什么是做批量重命名的命名空间在一个大的C#应用​​程序的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆