Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract interface from class in Visual Studio 2017

The functionality to extract an interface from a class (C#) seems to change in VS 2017. How can I do that in Visual Studio 2017.

like image 301
Wheel Builder Avatar asked Apr 19 '17 01:04

Wheel Builder


People also ask

How do I extract an interface?

Place your cursor in the class name. Press Ctrl+R, then Ctrl+I. (Your keyboard shortcut may be different based on which profile you've selected.) Press Ctrl+. to trigger the Quick Actions and Refactorings menu and select Extract Interface from the Preview window popup.


2 Answers

Right-click the class name and select "Quick Actions and Refactorings..." and then select "Extract interface..."

Note that you can also click on the class name and press Ctrl+. to bring up the same context menu.

like image 178
DiplomacyNotWar Avatar answered Oct 05 '22 10:10

DiplomacyNotWar


With ReSharper installed, right click the class name: Refactor > Extract > Extract Interface...

Keep in mind that the Extract Interface... option is not even in the menu if the class is static. The same goes for the class members if they do not appear in the menu where you select what goes in the interface.

I completely forgot that you cannot have a static class with an interface or extends at all for that matter.

like image 42
Heki Avatar answered Oct 05 '22 12:10

Heki