Aug 27, 2010

ReSharper’s Pull Members Up… Refactoring

I’ve long known about Resharper’s (R#)Extract Interface refactoring. I tend to write the actual implementation of a class and use Extract Interface to create the interface after the first pass. Of course during the course of a project I often end up adding methods to a class that implements an Interface, and those methods need to be in the interface as well.

imageR# contains an additional refactoring that is very useful but somewhat buried in a non-obvious spot. You can bring it up like any other refactoring but it’s extra-convenient to right-click in a method you want to add to the interface. In the context-menu select the Refactor option and choose Refactor This…

imageAnother context menu will appear with a series of options. The one you want in this case is Pull Members Up. After selecting that you will get a final dialog that allows you to select the methods you want to pull up. If your class also happens to be derived the top portion of the dialog will allow you to specify whether you want to pull members up into the base class or into the interface.



About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.