Backwards compatibility when changing base class

一曲冷凌霜 提交于 2019-12-24 09:27:35

问题


In .NET, do I maintain binary compatibility when I set a new base class for a class that earlier didn't have any base class (inherits from System.Object)?


回答1:


A quick test suggests it's okay, but personally I'd be very nervous of doing this without recompilation. You would basically be in a state which you couldn't reproduce from source code without going through the same steps - build the library, build the calling code, change the library, rebuild just the library code.

Behaviour can change in subtle ways with things like extension methods and overloading. It's much cleaner if you can rebuild all the calling code as well, so you're on firmer ground when it comes to debugging etc. If you find there's a bug in some interaction between the library and the calling code, you'd have to be really careful about how you analysed, tested and debugged it, if you couldn't just rebuild everything and get the same results.




回答2:


There shouldn't be any problem unless the base class changes the old behavior in some way.



来源:https://stackoverflow.com/questions/5321880/backwards-compatibility-when-changing-base-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!