diff --git a/AUTHORS.md b/AUTHORS.md index 912831836..92f1a4a97 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -84,3 +84,4 @@ - ([@DanBarzilian](https://github.com/DanBarzilian)) - ([@alxnull](https://github.com/alxnull)) - ([@gpetrou](https://github.com/gpetrou)) +- Ehsan Iran-Nejad ([@eirannejad](https://github.com/eirannejad)) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf64c3a64..60548ae10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,7 @@ Instead, `PyIterable` does that. - Empty parameter names (as can be generated from F#) do not cause crashes - Unicode strings with surrogates were truncated when converting from Python - `Reload` mode now supports generic methods (previously Python would stop seeing them after reload) +- Temporarily fixed issue resolving method overload when method signature has `out` parameters ([#1672](i1672)) ### Removed @@ -881,3 +882,4 @@ This version improves performance on benchmarks significantly compared to 2.3. [i1342]: https://github.com/pythonnet/pythonnet/issues/1342 [i238]: https://github.com/pythonnet/pythonnet/issues/238 [i1481]: https://github.com/pythonnet/pythonnet/issues/1481 +[i1672]: https://github.com/pythonnet/pythonnet/pull/1672 \ No newline at end of file diff --git a/src/runtime/MethodBinder.cs b/src/runtime/MethodBinder.cs index 42d3822fc..8b9ee9c00 100644 --- a/src/runtime/MethodBinder.cs +++ b/src/runtime/MethodBinder.cs @@ -632,6 +632,11 @@ static BorrowedReference HandleParamsArray(BorrowedReference args, int arrayStar margs[paramIndex] = defaultArgList[paramIndex - pyArgCount]; } + if (parameter.ParameterType.IsByRef) + { + outs++; + } + continue; } @@ -817,6 +822,9 @@ static bool MatchesArgumentCount(int positionalArgumentCount, ParameterInfo[] pa defaultArgList.Add(parameters[v].GetDefaultValue()); defaultsNeeded++; } + else if (parameters[v].IsOut) { + defaultArgList.Add(null); + } else if (!paramsArray) { match = false; diff --git a/tests/test_method.py b/tests/test_method.py index e81652b54..e2d8d5b06 100644 --- a/tests/test_method.py +++ b/tests/test_method.py @@ -280,6 +280,16 @@ def test_string_out_params(): assert result[1] == "output string" +def test_string_out_params_without_passing_string_value(): + """Test use of string out-parameters.""" + # @eirannejad 2022-01-13 + result = MethodTest.TestStringOutParams("hi") + assert isinstance(result, tuple) + assert len(result) == 2 + assert result[0] is True + assert result[1] == "output string" + + def test_string_ref_params(): """Test use of string byref parameters.""" result = MethodTest.TestStringRefParams("hi", "there") @@ -308,6 +318,16 @@ def test_value_out_params(): MethodTest.TestValueOutParams("hi", None) +def test_value_out_params_without_passing_string_value(): + """Test use of string out-parameters.""" + # @eirannejad 2022-01-13 + result = MethodTest.TestValueOutParams("hi") + assert isinstance(result, tuple) + assert len(result) == 2 + assert result[0] is True + assert result[1] == 42 + + def test_value_ref_params(): """Test use of value type byref parameters.""" result = MethodTest.TestValueRefParams("hi", 1) @@ -336,6 +356,15 @@ def test_object_out_params(): assert isinstance(result[1], System.Exception) +def test_object_out_params_without_passing_string_value(): + """Test use of object out-parameters.""" + result = MethodTest.TestObjectOutParams("hi") + assert isinstance(result, tuple) + assert len(result) == 2 + assert result[0] is True + assert isinstance(result[1], System.Exception) + + def test_object_ref_params(): """Test use of object byref parameters.""" result = MethodTest.TestObjectRefParams("hi", MethodTest()) @@ -364,6 +393,15 @@ def test_struct_out_params(): MethodTest.TestValueRefParams("hi", None) +def test_struct_out_params_without_passing_string_value(): + """Test use of struct out-parameters.""" + result = MethodTest.TestStructOutParams("hi") + assert isinstance(result, tuple) + assert len(result) == 2 + assert result[0] is True + assert isinstance(result[1], System.Guid) + + def test_struct_ref_params(): """Test use of struct byref parameters.""" result = MethodTest.TestStructRefParams("hi", System.Guid.NewGuid())
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: