How to auto generate constructors in child classes?

I have a BaseClass and a dozen of child classes derived from it. All children override certain methods and no custom constructor is defined. Later I realized that BaseClass requires some parameters and they need to be passed via constructor. I added constructor to my BaseClass and of course all child classes got broken. Now I need to go through all child classes and add a call to base constructor like so:

public ChildClass(int param) : base(param) {}

Is there a way to accomplish this using Resharper? If not can this feature be added to a wish list, I think it might be useful

Thank you

Comment actions Permalink

The shortest way that I know is with 3 shortcuts per derived class:

0: Create constructor in base class.
1: Press Alt+Shift+PageDown to go to next error (derived class).
2: Press Alt+Enter to open context action list.
3: Press Enter to run first action (Generate constructor).
4: Go to 1 for next derived class.

Comment actions Permalink

This is the best "manual" way of doing this (I would not have thought of using Alt+Shift+PageDown)

Thank you Markus!


Please sign in to leave a comment.