8000 1776 Inherit Generic Virtual Method Bug: Unit Test · pythonnet/pythonnet@ab531f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab531f8

Browse files
committed
1776 Inherit Generic Virtual Method Bug: Unit Test
Added a unit test which consists ofa python class inheriting from a C# class which has a virtual generic method. In this version, this causes a InvalidProgramException to be thrown during class creation.
1 parent fb17907 commit ab531f8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/testing/generictest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,12 @@ public static T[] EchoRange<T>(T[] items)
136136
return items;
137137
}
138138
}
139+
140+
public abstract class GenericVirtualMethodTest
141+
{
142+
public virtual Q VirtMethod<Q>(Q arg1)
143+
{
144+
return arg1;
145+
}
146+
}
139147
}

tests/test_subclass.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
8000
99
import System
1010
import pytest
1111
from Python.Test import (IInterfaceTest, SubClassTest, EventArgsTest,
12-
FunctionsTest)
12+
FunctionsTest, GenericVirtualMethodTest)
1313
from System.Collections.Generic import List
1414

1515

@@ -264,6 +264,12 @@ class TestX(System.Object):
264264
t = TestX()
265265
assert t.q == 1
266266

267+
def test_virtual_generic_method():
268+
class OverloadingSubclass(GenericVirtualMethodTest):
269+
__namespace__ = "test_virtual_generic_method_cls"
270+
obj = OverloadingSubclass()
271+
assert obj.VirtMethod[int](5) == 5
272+
267273
def test_construction_from_clr():
268274
import clr
269275
calls = []

0 commit comments

Comments
 (0)
0