Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added fix for calling virtual method on baseclass which is not defined.
  • Loading branch information
rmadsen-ks authored and filmor committed Mar 25, 2026
commit 23df0e8d9ff498b0b0e4d3e5cc98d7a72387debe
2 changes: 1 addition & 1 deletion src/runtime/Types/ClassDerived.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private static void AddVirtualMethod(MethodInfo method, Type baseType, TypeBuild
string? baseMethodName = null;
if (!method.IsAbstract)
{
baseMethodName = "_" + baseType.Name + "__" + method.Name;
baseMethodName = "_" + method.DeclaringType.Name + "__" + method.Name;
MethodBuilder baseMethodBuilder = typeBuilder.DefineMethod(baseMethodName,
MethodAttributes.Public |
MethodAttributes.Final |
Expand Down
5 changes: 5 additions & 0 deletions src/testing/classtest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ public virtual string SayGoodbye()
return "!";
}
}

public class SimpleClass2 : SimpleClass
{
// this class does not override SayGoodbye.
}
}
4 changes: 2 additions & 2 deletions tests/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import System
import pytest
from Python.Test import (IInterfaceTest, SubClassTest, EventArgsTest,
FunctionsTest, IGenericInterface, GenericVirtualMethodTest, SimpleClass, ISayHello1)
FunctionsTest, IGenericInterface, GenericVirtualMethodTest, SimpleClass, SimpleClass2, ISayHello1)
from System.Collections.Generic import List


Expand Down Expand Up @@ -355,7 +355,7 @@ def test_multi_level_subclass():
exception if a method was not implemented in the middle of the tree.
"""
import clr
class DualSubClass0(ISayHello1, SimpleClass):
class DualSubClass0(ISayHello1, SimpleClass2):
__namespace__ = "Test"
def SayHello(self):
return "hello"
Expand Down