Title: Wrap returned objects in interface if method return type is interface by danabr · Pull Request #1240 · pythonnet/pythonnet · GitHub
Open Graph Title: Wrap returned objects in interface if method return type is interface by danabr · Pull Request #1240 · pythonnet/pythonnet
X Title: Wrap returned objects in interface if method return type is interface by danabr · Pull Request #1240 · pythonnet/pythonnet
Description: What does this implement/fix? Explain your changes. 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: 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: 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. Does this close any currently open issues? No. Any other comments? See #1233 for an alternative approach, that exposes methods of explictly implemented interfaces without need to cast the object first. Checklist Check all those that are applicable and complete. Make sure to include one or more tests for your change If an enhancement PR, please create docs and at best an example Add yourself to AUTHORS Updated the CHANGELOG
Open Graph Description: What does this implement/fix? Explain your changes. This allows callers to call all methods of an interface, regardless of whether the method was implemented implicitly or explicitly. Before this c...
X Description: What does this implement/fix? Explain your changes. This allows callers to call all methods of an interface, regardless of whether the method was implemented implicitly or explicitly. Before this c...
Opengraph URL: https://github.com/pythonnet/pythonnet/pull/1240
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:5396032a-5db7-4dd0-0404-cb11ca5dd80e |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | CB0C:EB10B:20860CA:2C2C5C5:69708605 |
| html-safe-nonce | 7bee820676a00f8c0eaef2036d39699642aabb13b4cd7e7b172c121c5b919138 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjBDOkVCMTBCOjIwODYwQ0E6MkMyQzVDNTo2OTcwODYwNSIsInZpc2l0b3JfaWQiOiI4Mzg1NTUwMTY5NzM3ODIzNzQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3b1202b0882780066177f6f10759874dcb25dc16c3acfe5ba82797e259d4fac9 |
| hovercard-subject-tag | pull_request:493386321 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/pythonnet/pythonnet/pull/1240/checks |
| twitter:image | https://avatars.githubusercontent.com/u/207266?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/207266?s=400&v=4 |
| og:image:alt | What does this implement/fix? Explain your changes. This allows callers to call all methods of an interface, regardless of whether the method was implemented implicitly or explicitly. Before this c... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width