在Visual Studio 中为接口中所有定义的方法生成方法存根的快捷方式是什么?
What is the shortcut to generate method-stubs for all defined methods in the interface in Visual Studio?
我在 Visual Studio 2012 年(或 2010 年)从事 C# 项目,该项目由我之前的许多人开发并向其添加功能。由于自上一个人处理后需求发生了变化,我需要向接口添加一个新方法,其中大约有 15 个左右的具体 classes 正在实现。所有的实现都不同。
添加新方法签名后,我现在无法编译和 运行 项目,因为所有 15 classes 都没有新添加方法的方法存根。以前,我通过转到每个 class 并从上下文菜单中选择实施所有方法或使用快捷键来采用手动路线。
我以前做的:转到实现接口的class,点击菜单中的选项生成所有方法存根,冲洗并重复。
我想知道的: Visual Studio 中是否有一个快捷方式可以自动将所有方法存根插入到每个具体 class 中已经实现了接口?
我知道在创建实现接口的新 classes 时很容易做到这一点,但是这些 classes 中已经有大量代码。顺便说一句,我也不想继承 class。
我要实现的目标与 This Eclipse SO question, that also has no answer
类似
到目前为止我发现的 是仍然需要我打开 15 个 class 中的每一个并手动生成存根的快捷方式,这些存根如果没有已知的方法,我将不得不求助于此:
Generate implementations of base class methods
Implement inherited methods
Shortcut key to implement interface
具体例子:
//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?
(如果不缩进就无法 post 这个问题)
我找到了这个免费扩展:
也许它可以帮助你,因为他们提到了这条评论:
"As Doris, the developer, I can generate unit test stubs against multiple frameworks so that I can utilize any framework I'd like."
让我知道这是否适合你...
据我所知,没有一种免费且简单的方法可以做到这一点,但可以通过使用 ReSharper 来实现,这是一个 Jetbrains 扩展,30 天后需要付费。这是代码生成功能。因此,截至 Visual Studio 2012 年,它没有快捷方式或内置功能。
我在 Visual Studio 2012 年(或 2010 年)从事 C# 项目,该项目由我之前的许多人开发并向其添加功能。由于自上一个人处理后需求发生了变化,我需要向接口添加一个新方法,其中大约有 15 个左右的具体 classes 正在实现。所有的实现都不同。
添加新方法签名后,我现在无法编译和 运行 项目,因为所有 15 classes 都没有新添加方法的方法存根。以前,我通过转到每个 class 并从上下文菜单中选择实施所有方法或使用快捷键来采用手动路线。
我以前做的:转到实现接口的class,点击菜单中的选项生成所有方法存根,冲洗并重复。
我想知道的: Visual Studio 中是否有一个快捷方式可以自动将所有方法存根插入到每个具体 class 中已经实现了接口?
我知道在创建实现接口的新 classes 时很容易做到这一点,但是这些 classes 中已经有大量代码。顺便说一句,我也不想继承 class。
我要实现的目标与 This Eclipse SO question, that also has no answer
类似到目前为止我发现的 是仍然需要我打开 15 个 class 中的每一个并手动生成存根的快捷方式,这些存根如果没有已知的方法,我将不得不求助于此:
Generate implementations of base class methods
Implement inherited methods
Shortcut key to implement interface
具体例子:
//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?
(如果不缩进就无法 post 这个问题)
我找到了这个免费扩展:
也许它可以帮助你,因为他们提到了这条评论: "As Doris, the developer, I can generate unit test stubs against multiple frameworks so that I can utilize any framework I'd like."
让我知道这是否适合你...
据我所知,没有一种免费且简单的方法可以做到这一点,但可以通过使用 ReSharper 来实现,这是一个 Jetbrains 扩展,30 天后需要付费。这是代码生成功能。因此,截至 Visual Studio 2012 年,它没有快捷方式或内置功能。