114

I'm adding a new method to a class that implements an interface, and I like to use the "Extract Interface" refactoring and just add the method to the interface. But it doesn't seem like ReSharper supports adding a method signature to an already existing interface.

It feels like I'm missing something, I'm sure it can be done somehow. Maybe I should add the method signature to the interface first, but this is the way I'm working sometimes. Am I missing some shortcut, feature or using ReSharper wrong?

Johan Danforth
  • 4,469
  • 6
  • 37
  • 36

1 Answers1

214

Ctrl+Shift+R to access the refactoring menu then choose Pull Members Up...

You can choose the interface that you want to add the declarations to and also select each method that you want to add to the interface.

Gotta love Resharper! ;-)

Russell Giddings
  • 8,731
  • 5
  • 34
  • 35
  • 6
    ARgh! I didn't even try that option because I thought it had to do with inherited base classes only. I could bet Extract Interface was the right choice... Anyway, thanks! – Johan Danforth Feb 21 '10 at 15:05
  • 2
    Yep, I had exactly the same experience, Extract Interface seems the most intuitive option but hey, at least we've got a way to achieve the desired result :-) – Russell Giddings Feb 21 '10 at 21:30
  • I don't see it is working or existing in new ReSharper version – RJN May 23 '18 at 14:09
  • 1
    It's still working... but cannot detect existing interface and put new methods inside it. – Ingweland Sep 10 '19 at 07:17
  • @RJN Make sure the class you are in already implements the interface. – Greg Quinn Sep 18 '19 at 02:11