Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 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.

like image 814
Gordon Mackie JoanMiro Avatar asked Aug 06 '09 13:08

Gordon Mackie JoanMiro


1 Answers

As often, ReSharper can help you. There is an option (under menu: Refactor) called "pull members up" where you can select members to be moved to the base class.
There is an option "push members down for the other direction, too.

like image 177
tanascius Avatar answered Oct 20 '22 10:10

tanascius