@@ -1402,6 +1402,31 @@ def call_method_with_enum():
14021402 Assert.AreEqual(DayOfWeek.Monday, CSharpModel.ProvidedArgument);
14031403 }
14041404
1405+ [TestCase("call_non_generic_method", "GenericOverloadTestMethod")]
1406+ [TestCase("call_generic_method", "GenericOverloadTestMethod<T>")]
1407+ public void ResolvesToGenericOnlyWhenExplicitlyCalled(string pythonFuncToCall, string expectedMethodCalled)
1408+ {
1409+ using var _ = Py.GIL();
1410+
1411+ var module = PyModule.FromString($"ResolvesToGenericOnlyWhenExplicitlyCalled_{pythonFuncToCall}", @$"
1412+ from clr import AddReference
1413+ AddReference(""System"")
1414+ from Python.EmbeddingTest import *
1415+
1416+ def call_non_generic_method():
1417+ return TestMethodBinder.CSharpModel.GenericOverloadTestMethod(TestMethodBinder.CSharpModel(), 'Test')
1418+
1419+ def call_generic_method():
1420+ return TestMethodBinder.CSharpModel.GenericOverloadTestMethod[TestMethodBinder.CSharpModel](TestMethodBinder.CSharpModel(), 'Test')
1421+ ");
1422+
1423+ Assert.DoesNotThrow(() =>
1424+ {
1425+ using var result = module.GetAttr(pythonFuncToCall).Invoke();
1426+ });
1427+ Assert.AreEqual(expectedMethodCalled, CSharpModel.LastFuncCalled);
1428+ }
1429+
14051430 // Used to test that we match this function with Py DateTime & Date Objects
14061431 public static int GetMonth(DateTime test)
14071432 {
@@ -1636,6 +1661,18 @@ public static void TestAction3(CSharpModel model1, CSharpModel model2)
16361661 }
16371662 LastFuncCalled = "TestAction3";
16381663 }
1664+
1665+ public static string GenericOverloadTestMethod(CSharpModel testArg1, string testArg2, decimal testArgs3 = 0m)
1666+ {
1667+ LastFuncCalled = "GenericOverloadTestMethod";
1668+ return string.Empty;
1669+ }
1670+
1671+ public static T GenericOverloadTestMethod<T>(CSharpModel testArg1, string testArg2, decimal testArgs3 = 0m)
1672+ {
1673+ LastFuncCalled = "GenericOverloadTestMethod<T>";
1674+ return default;
1675+ }
16391676 }
16401677
16411678 public class TestImplicitConversion
0 commit comments