4

I have a large set of auto generated classes which share about 90% of their properties. Is there a way using Visual Studio or Resharper to extract all the common properties into a parent class and make all the classes descend from the parent?

jcvandan
  • 14,124
  • 18
  • 66
  • 103

1 Answers1

2

Unless there's something I'm missing, you can do this with the Extract Superclass refactoring (maybe a bit misleading name, in .NET world this would be better called "base class")

On the class name, press Ctrl+Shift+R, select Extract Superclass, select all the properties you want to move. ReSharper will generate a new class, and will move those properties to it.

If you already have such base class, you can select the option Pull members up, which will let you "pull" properties to a base class.

Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157
  • 5
    I am aware of the extract superclass command, but I thought that only worked on one class at a time? I have a batch of around 50 classes, all with only minor differences. I want to be able to run a command like extract superclass, but on all classes at the same time. – jcvandan Jul 31 '14 at 08:19