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 reproduced this issue at our end; it does look like Python.NET engine does not validate arguments of this kind. We will try to get their comments on this issue.