-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Fix deserialization of delegates that are 0-parameter overloads #78877
Conversation
Thanks ahead of time for your patience with my first PR. Happy to go back and add more details or spend some more time on a cohesive repro. I ran into this working on an editor plugin. It threw every time I compiled my code. This fix worked for me. |
Please open an issue to track this more effectively, in case some other solution is required, or something else is wrong, and to handle the specifics of the issue |
On it, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing to the .NET module!
Indeed, the Type.GetMethod
documentation says that it throws an exception if:
More than one method is found with the specified name and matching the specified binding constraints.
So if we are specifically looking for a method with no parameters, we should be using the overload that takes a parameter type array.
This PR already looks good to me 👍, but I'd like you to make a small change to avoid allocating empty arrays.
Created #78886. |
Re-tested with your change @raulsntos. Works just as well! thanks for the feedback! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good so I'm approving, but before we can merge you'll have to squash the commits into one.
Since it's your first time contributing, make sure to take a look at CONTRIBUTING.md and the contributing documentation if you haven't already. It contains information about squashing, in case you need it.
Feel free to reach out in the development chat if you need help.
Co-authored-by: Raul Santos <raulsntos@gmail.com>
Thanks! And congrats on your first merged Godot PR! Please consider in the future creating a feature branch for your PR instead of using your |
Cherry-picked for 4.1.2. |
TryDeserializeSingleDelegate
causesGetMethod
to throw when deserializing a method with a 0-parameter overload.GetMethod
without atypes
argument matches all methods with the givenname
, whereas a 0-lengthtypes
argument explicitly matches methods with 0 parameters.E.g.