简体   繁体   English

合并Base和派生C#类的工具

[英]Tool to coalesce Base and Derived C# Classes

Does anyone know of a tool or VS add-in that will allow me to take a base class and a derived class, and collapse them into a single 'flattened' class? 有没有人知道一个工具或VS加载项,它将允许我采用基类和派生类,并将它们折叠成一个“扁平”类? Or is this too difficult an operation, given the need to cope with resolving overriden and hidden/new members? 或者这是一项操作太难,因为需要解决重写和隐藏/新成员的问题?

Background: I am working on a project where we have a base class and a single derived class that was going to be the first of a few others. 背景:我正在开发一个项目,我们有一个基类和一个派生类,它将成为其他几个中的第一个。

Subsequent analysis work means that the other class will now not be necessary and the specialisation is just proving confusing for coders coming new to the codebase. 后续的分析工作意味着现在没有必要使用另一个类,并且专业化只会让代码库新来的编码人员感到困惑。 I'd like to merge the base and the derived class to simplify things (and simplify the database mapping in nHibernate), but both are quite large - so I thought it would be worth checking if a tool could do the job. 我想合并基类和派生类来简化事情(并简化nHibernate中的数据库映射),但两者都非常大 - 所以我认为值得检查一个工具是否可以完成这项工作。

As often, ReSharper can help you. 通常, ReSharper可以帮助您。 There is an option (under menu: Refactor) called "pull members up" where you can select members to be moved to the base class. 有一个选项(在菜单下:Refactor),称为“pull members up”,您可以在其中选择要移动到基类的成员。
There is an option "push members down for the other direction, too. 有一个选项“推动成员向另一个方向下来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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