You might just add some simple APIs in your library and you’ll not think that will break down your compatibility. But actually, it might, that is – the source-code compatibility.
This post is written in multiple languages. Please select yours:
中文 English
Assume that we’ve written a project P which references another two libraries A and B. And we have a Walterlv.A.Diagnostics.Foo
class in library A.
1 2 3 4 5 6 7 8 9 10 11 12 | using Walterlv.A; using Walterlv.B; namespace Walterlv.Demo { class Hello { Run(Diagnostics.Foo foo) { } } } |
---|
And now we add a new class Walterlv.B.Diagnostics.Bar
class into the B library. That is adding a new API only.
Unfortunately, the code above would fail to compile because of the ambiguity of Diagnostics
namespace. The Foo
class cannot be found in an ambiguity namespace.
I write this post down to tell you that there may be source-code compatibility issue even if you only upgrade your library by simply adding APIs.
本文会经常更新,请阅读原文: https://blog.walterlv.com/post/source-code-compatibility-issue-of-adding-apis-en.html ,以避免陈旧错误知识的误导,同时有更好的阅读体验。
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名 吕毅 (包含链接: https://blog.walterlv.com ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请 与我联系 ([email protected]) 。