在Visual Studio中有效地传播接口更改 [英] Efficiently Propagating Interface Changes in Visual Studio

查看:173
本文介绍了在Visual Studio中有效地传播接口更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我深入研究解耦和依赖注入的世界时,我发现自己编写了越来越多的接口。我尽力创建接口,确切地知道我将如何使用它们,但总有一种情况是我最终实现了接口,然后改变了它的使用方式。

As I delve into the world of decoupling and dependency injection, I'm finding myself writing more and more interfaces. I try my best to create interfaces knowing exactly how I'm going to use them, but there's always the case that I end up implementing the interface and then changing how it's used.

我已经习惯了VS的自动重构能力。但我发现它不支持将接口更改自动传播到实现类。有没有办法自动执行此操作,因此在编译错误消失之前我不会复制和粘贴?

I've become accustomed to VS' automatic refactoring ability. But I've found that it doesn't support propagating interface changes automatically to the implementing classes. Is there a way to do this automatically so I'm not copying and pasting until my compile errors go away?

推荐答案

想要回过头来回答这个问题:

Wanted to come back and answer this question:

如果要更改接口方法名称,如果从实例化类中更改它,Visual Studio将为您提供传播选项它接口(以及整个代码中的所有其他调用,正常情况下)。如果在接口定义中更改方法名称,则更改将不会传播到实例化类。

If you want to change an interface method name, if you change it from the instantiating class, Visual Studio will give you the option to propagate it to the interface (as well as all other calls throughout your code, as normal). If you change the method name in the interface definition, the change will not propagate to the instantiating classes.

这篇关于在Visual Studio中有效地传播接口更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆