Cannot implement an interface that extends another interface
See original GitHub issueEnvironment
- Pythonnet version: 3.0.0a2
- Python version: 3.8.10
- Operating System: Ubuntu 20.04.4 LTS (docker run --rm -it ubuntu:20.04)
- .NET Runtime: .NET Core 6.0.202
Details
-
Describe what you were trying to get done.
Attempting to implement interfaces defined in .NET. Works fine for simple interfaces but I receive a weird error when the interface extends IDisposable
-
What commands did you run to trigger this issue? If you can provide a Minimal, Complete, and Verifiable example this will help us understand the issue.
from clr_loader import get_coreclr
rt = get_coreclr("conf.json")
from pythonnet import set_runtime
set_runtime(rt)
import clr
import System
import System.Buffers
class MyDisposable(System.IDisposable):
__namespace__ = "MyNamespace"
def Dispose(self) -> None:
print("Dispose")
md = MyDisposable()
md.Dispose()
class MyBuffer(System.Buffers.IMemoryOwner):
__namespace__ = "MyNamespace"
def Dispose(self) -> None:
print("Dispose")
mb = MyBuffer()
mb.Dispose()
conf.json:
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.4"
}
}
}
- If there was a crash, please include the traceback here.
(venv) root@ca20f043eef5:/t# python demo.py
Dispose
Traceback (most recent call last):
File "demo.py", line 21, in <module>
class MyBuffer(System.Buffers.IMemoryOwner):
TypeError: Method 'Dispose' in type 'MyNamespace.MyBuffer' from assembly 'Python.Runtime.Dynamic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
java - Why an interface can not implement another interface?
Implements denotes defining an implementation for the methods of an interface. However interfaces have no implementation so that's not possible.
Read more >Why an Interface Can Not Implement Another Interface
One interface can only extend other interface but cannot implement the other interface as interface can only have method declarations and not the...
Read more >Can an interface implement another interface?
Yes. One interface can inherit another by use of the keyword extends. The syntax is the same as for inheriting classes. When a...
Read more >Defining an Interface - The Java™ Tutorials
An interface can extend other interfaces, just as a class subclass or extend another class. However, whereas a class can extend only one...
Read more >java - Why does an interface extend an interface instead of ...
Interface implementation implies a finality that cannot be created by another interface - by their nature, an interface is meant to be ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error has nothing specifically to do with IDisposable. Any interface that extends a second interface shows this problem:
I’m seeing the same error with this for example: