Method overload object type by vmuriart · Pull Request #377 · pythonnet/pythonnet
@vmuriart here is what I suggested to add. I cannot test locally, due to #385
public static string TestOverloadedObject(object o) { return "Got object"; } public static string TestOverloadedObjectTwo(int a, int b) { return "Got int-int"; } public static string TestOverloadedObjectTwo(string a, string b) { return "Got string-string"; } public static string TestOverloadedObjectTwo(string a, int b) { return "Got string-int"; } public static string TestOverloadedObjectTwo(string a, object b) { return "Got string-object"; } public static string TestOverloadedObjectTwo(int a, object b) { return "Got int-object"; } public static string TestOverloadedObjectTwo(object a, int b) { return "Got object-int"; } public static string TestOverloadedObjectTwo(object a, object b) { return "Got object-object"; } public static string TestOverloadedObjectThree(object a, int b) { return "Got object-int"; } public static string TestOverloadedObjectThree(int a, object b) { return "Got int-object"; }
def test_object_in_multiparam(): """Test method with object multiparams behaves""" res = MethodTest.TestOverloadedObjectTwo(5, 5) assert res == "Got int-int" res = MethodTest.TestOverloadedObjectTwo(5, "foo") assert res == "Got int-object" res = MethodTest.TestOverloadedObjectTwo("foo", 5) assert res == "Got object-int" res = MethodTest.TestOverloadedObjectTwo("foo", "bar") assert res == "Got object-object" res = MethodTest.TestOverloadedObjectTwo("foo", System.Object) assert res == "Got string-object" res = MethodTest.TestOverloadedObjectTwo("foo", "bar") assert res == "Got string-string" res = MethodTest.TestOverloadedObjectTwo("foo", 5) assert res == "Got string-int"