Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This one is a perhaps not-so-obvious special case of "adding/removing interface members", and I figured it deserves its own entry in light of another case which I'm going to post next. So:</p> <h2>Refactoring interface members into a base interface</h2> <p>Kind: breaks at both source and binary levels</p> <p>Languages affected: C#, VB, C++/CLI, F# (for source break; binary one naturally affects any language)</p> <p>API before change:</p> <pre><code>interface IFoo { void Bar(); void Baz(); } </code></pre> <p>API after change:</p> <pre><code>interface IFooBase { void Bar(); } interface IFoo : IFooBase { void Baz(); } </code></pre> <p>Sample client code that is broken by change at source level:</p> <pre><code>class Foo : IFoo { void IFoo.Bar() { ... } void IFoo.Baz() { ... } } </code></pre> <p>Sample client code that is broken by change at binary level;</p> <pre><code>(new Foo()).Bar(); </code></pre> <p>Notes:</p> <p>For source level break, the problem is that C#, VB and C++/CLI all require <em>exact</em> interface name in the declaration of interface member implementation; thus, if the member gets moved to a base interface, the code will no longer compile. </p> <p>Binary break is due to the fact that interface methods are fully qualified in generated IL for explicit implementations, and interface name there must also be exact.</p> <p>Implicit implementation where available (i.e. C# and C++/CLI, but not VB) will work fine on both source and binary level. Method calls do not break either.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload