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?
Asked
Active
Viewed 526 times
4
-
Wow can't believe I've got SO stumped - this is a first – jcvandan Jul 30 '14 at 11:42
-
Why do you want to refactor auto generated code as when you re-generate it it will just overwrite all your changes? – Piers Myers Jul 30 '14 at 11:50
-
1Its just a one off thing, I have generated a batch of classes from a load of XML using xsd.exe, they won't be done again – jcvandan Jul 30 '14 at 12:47
1 Answers
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
-
5I 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