Does the function return type for the child type change binary compatibility?
Let's go straight to it:
Old code:
public interface IFoo {}
public class Foo : IFoo {}
...
public static IFoo Bar() { return new Foo(); }
New code:
public static Foo Bar() { return new Foo(); }
Obviously there shouldn't be any problem here, whatever you did with the old return type, you can still use the new return type, any is
, as
or cast should behave the same as before ...
So I broke binary compatibility, or can I just let it go as a minor version without bothering users?
+3
source to share
2 answers
You may have problems with people who have created unit tests around your code. Since these are static people could create FooAdapater like this: -
public class FooAdapater(){
public IFoo GetFoo() { Return your static Bar; }
}
They could then create a mocking foo adapter than return fooed foo. Your code will break this scenario.
So no, this is not binary compatible :-)
-1
source to share