问题
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.
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?
回答1:
Since Visual Studio, or any other tool can't "know" what the implementation should be, it falls to you, the developer to implement it.
If you change an interface definition, it is a good thing that compilation fails until you have implemented the change.
回答2:
Wanted to come back and answer this question:
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.
来源:https://stackoverflow.com/questions/7920579/efficiently-propagating-interface-changes-in-visual-studio