What is the shortcut to generate method-stubs for all defined methods in the interface in Visual Studio?

I'm working on a C# project in Visual Studio 2012 (or 2010) that has been developed by many people before me and adding functionality to it. As the requirements have changed since the last person worked on it, I need to add a new method to an interface, in which about 15 or so concrete classes are implementing. All the implementations differ.

Upon adding the new method signature, I now cannot compile and run the project because all the 15 classes do not have a method-stub for the newly added method. Previously I've taken the manual route by going to each class, and selecting implement all methods from a context menu, or by using the shortcut key.

What I used to do: Go to class that implements the interface, click on the options in the menu to generate all method stubs, rinse and repeat.

What I want to know: Is there a shortcut in in Visual Studio that will automatically insert all the method stubs in each concrete class that presently already implements the interface?

I know this is easily done when creating new classes that implement the interface, but these classes already have a ton of code in them. I'd prefer not to inherit the class too, by the way.

What I'm trying to achieve is similar to This Eclipse SO question, that also has no answer

What I've found so far are shortcuts that would still require me to open each of the 15 classes or so and manually generate the stubs, which is what I will have to resort to if there isn't a known way to do this:

Generate implementations of base class methods

Implement inherited methods

Shortcut key to implement interface

Concrete Example:

//I have a ICar interface, which 15 concrete classes implement. //Now I add a getEngineHorsePower() //method signature in ICar, //is there a quick way to generate method stubs (that will throw new NotImplementedException() //when called) for all 15 classes?

(Couldn't post the question without indenting this)

-------------Problems Reply------------

I've found this free extension:

Unit Test Generator

maybe it can help you as they mention this comment: "As Doris, the developer, I can generate unit test stubs against multiple frameworks so that I can utilize any framework I'd like."

let me know if that works for you...

As far as I know there isn't a free and simple way to do this, but it can be achieved by using ReSharper, a Jetbrains extension that costs money after 30-days. It's the Code Generation feature. Thus, as of Visual Studio 2012 there isn't a shortcut or built-in feature for it.

Category:c# Views:4 Time:2017-09-13

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.306 (s). 10 q(s)