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.
-
can you describe the expected behavior of older version VS? – Lei Yang Apr 19 '17 at 01:43
5 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.

- 36,677
- 7
- 67
- 86
-
-
3For some reason, I'm not seeing this behavior. I used it all the time in 2015, but now all I see is "Generate overrides..." – Oct 31 '17 at 20:51
-
5Huh. Looks like I have to add a public property or method to a class before I can interface it... I guess that makes sense... but I don't like it. – Oct 31 '17 at 21:02
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.

- 926
- 2
- 15
- 34
-
2See also [resharper extract interface grayed out](//stackoverflow.com/q/23850048) – Michael Freidgeim Aug 02 '18 at 02:20
Extract an interface refactoring
Place your cursor in the class name.
Press Ctrl+R, then Ctrl+I.
https://learn.microsoft.com/en-us/visualstudio/ide/reference/extract-interface?view=vs-2019

- 41
- 4
I had the same problem with Visual Studio Community 2019 and I fixed it by disabling Resharper.

- 21
- 2
For some users the menu on right click on the class seems be deleted and now you can access only by right clicking
on the class
that you want to create the interface and than click on Quick actions and refactoring
.

- 13
- 2