Skip to content

Cannot implement an interface that extends another interface #1783

@phxnsharp

Description

@phxnsharp

Environment

  • 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy