Title: Incorrect function resolution when calling overloads from python with keyword args · Issue #1097 · pythonnet/pythonnet · GitHub
Open Graph Title: Incorrect function resolution when calling overloads from python with keyword args · Issue #1097 · pythonnet/pythonnet
X Title: Incorrect function resolution when calling overloads from python with keyword args · Issue #1097 · pythonnet/pythonnet
Description: Environment Pythonnet version: 2.4.0 Python version: 3.6.5 Operating System: Centos Details Describe what you were trying to get done. When calling .NET functions with overloads from python with keyword args, the MethodBinder.Bind method...
Open Graph Description: Environment Pythonnet version: 2.4.0 Python version: 3.6.5 Operating System: Centos Details Describe what you were trying to get done. When calling .NET functions with overloads from python with ke...
X Description: Environment Pythonnet version: 2.4.0 Python version: 3.6.5 Operating System: Centos Details Describe what you were trying to get done. When calling .NET functions with overloads from python with ke...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1097
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect function resolution when calling overloads from python with keyword args","articleBody":"### Environment\r\n\r\n- Pythonnet version: 2.4.0\r\n- Python version: 3.6.5\r\n- Operating System: Centos\r\n\r\n### Details\r\n\r\n- Describe what you were trying to get done.\r\n\r\n When calling .NET functions with overloads from python with keyword args, the MethodBinder.Bind method will return the first method it finds which might not be the actual method the user is trying to call. Take the following simple C# code:\r\n\r\n```C#\r\npublic static string OptionalArgumentsMethod(int arg1, int arg2)\r\n{ \r\n return $\"{arg1}{arg2}XX\";\r\n}\r\n\r\npublic static string OptionalArgumentsMethod(int arg1, int arg2, int arg3 = 3)\r\n{\r\n return $\"{arg1}{arg2}{arg3}X\";\r\n}\r\n\r\npublic static string OptionalArgumentsMethod(int arg1, int arg2, int arg3 = 4, int arg4 = 5)\r\n{\r\n return $\"{arg1}{arg2}{arg3}{arg4}\";\r\n}\r\n```\r\n\r\nCalling, for example, `OptionalArgumentsMethod(1, 2, arg3=5)` we expect to get back `125X` but instead we see:\r\n```python\r\n\u003e\u003e\u003e OptionalArgumentsMethod(1, 2)\r\n'12XX'\r\n\u003e\u003e\u003e OptionalArgumentsMethod(1, 2, 3)\r\n'123X'\r\n\u003e\u003e\u003e OptionalArgumentsMethod(1, 2, arg3=5)\r\n'12XX'\r\n\u003e\u003e\u003e OptionalArgumentsMethod(1, 2, 3, 5)\r\n'1235'\r\n\u003e\u003e\u003e OptionalArgumentsMethod(1, 2, 3, arg4=5)\r\n'123X'\r\n\u003e\u003e\u003e OptionalArgumentsMethod(1, 2, arg4=0)\r\n'12XX'\r\n```\r\n","author":{"url":"https://github.com/jmlidbetter","@type":"Person","name":"jmlidbetter"},"datePublished":"2020-03-26T16:50:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1097/pythonnet/issues/1097"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3c65f2b0-cbc8-bb33-bdae-48035080644b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B37E:18CF34:935E99:CCDD25:6970B56F |
| html-safe-nonce | 56cfa17f6af054e62f161e8f368bb64a9bb1fefb4e3cb5fc00a29f1cd8f164ca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzdFOjE4Q0YzNDo5MzVFOTk6Q0NERDI1OjY5NzBCNTZGIiwidmlzaXRvcl9pZCI6IjY3Mjg0ODEyMjA2MjgzNjI2MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | de062888d4f4ca66b3fb133c93819f4ea5f1b10623b12fda29a7cf691a1bf2de |
| hovercard-subject-tag | issue:588568995 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/1097/issue_layout |
| twitter:image | https://opengraph.githubassets.com/72e59e8ea5ff7e8823320948059d21f4887ee35285b8ab8cba8658046ce19374/pythonnet/pythonnet/issues/1097 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/72e59e8ea5ff7e8823320948059d21f4887ee35285b8ab8cba8658046ce19374/pythonnet/pythonnet/issues/1097 |
| og:image:alt | Environment Pythonnet version: 2.4.0 Python version: 3.6.5 Operating System: Centos Details Describe what you were trying to get done. When calling .NET functions with overloads from python with ke... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jmlidbetter |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8e0be80373b724b033cdf8a7b1f78bf5fb6a5d7a2182a9a403aa30894606e390 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 84d9d5bf3b01412ea10f7c2429cbfc735ccce9ce |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width