You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrap returned objects in interface if method return type is interface
This allows callers to call all methods of an interface, regardless of
whether the method was implemented implicitly or explicitly. Before this
change, you had to make an explicit cast to the interface to be able to
call the explicitly implemented method. Consider the following code:
```C#
namespace Python.Test {
public interface ITestInterface
{
void Foo();
void Bar();
}
public class TestImpl : ITestInterface
{
public void Foo() { };
public void ITestInterface.Bar() { };
public void Baz() { };
public static ITestInterface GetInterface()
{
return new TestImpl();
}
}
}
```
And the following Python code, demonstrating the behavior before this
change:
```python
from Python.Test import TestImpl, ITestInterface
test = TestImpl.GetInterface()
test.Foo() # works
test.Bar() # AttributeError: 'TestImpl' object has no attribute 'Bar'
test.Baz() # works! - baz
```
After this change, the behavior is as follows:
```
test = TestImpl.GetInterface()
test.Foo() # works
test.Bar() # works
test.Baz() # AttributeError: 'ITestInterface' object has no attribute 'Baz'
```
This is a breaking change due to that `Baz` is no longer visible in
Python.
0 commit comments