Implement coerce logic for net method binding by generalloki · Pull Request #2590 · pythonnet/pythonnet
I am not sure what you suggest to overload. Initially our customer reported the problem. Here is his request:
When accessing a .NET function using PythonNET bindings I noticed that if a kwarg is incorrect or doesn’t exist it is discarded by the PythonNET parser. For example
If I have a .NET function like this:
Public Function SomeFunction(name as String, age as String) as String Return $"{name} - {age}" End Function
And I call it in PythonNET like this:
if __name__ == "__main__": name = "John" age = "3" SomeFunction(name, age=age, fake_arg="something")
The fake arg is discarded and no error or exception is thrown. The python compiles as if the additional kwarg is not there. In this situation normal python would be throwing a TypeError.
This is an issue for us when we have multiple kwargs in our methods/functions that a user can easily misspell and result in unexpected behaviour.
We posted an issue about kwargs but it is not fixed from that moment, so we suggest an improvement that will allow bind a customizable event which is fired before .net method is called. In the implementation of this event we can fix the issue and also add some other security related logic