Skip to content
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

Fix C# get_all_delegates method for generic classes #55563

Merged

Conversation

raulsntos
Copy link
Member

@raulsntos raulsntos commented Dec 2, 2021

If the class is generic, we must get its generic type definition and use it to retrieve the delegates.

Closes #47830


I tested this PR using the 3.x version (#55564) because there seems to be an issue in master with the Source Generators and generic types.

@raulsntos raulsntos requested a review from a team as a code owner December 2, 2021 21:17
@aaronfranke aaronfranke added this to the 4.0 milestone Dec 2, 2021
@raulsntos raulsntos force-pushed the csharp-delegates-for-generic-class branch from 2bf3073 to b45990d Compare December 2, 2021 21:21
@aaronfranke aaronfranke requested a review from neikeq December 2, 2021 21:22
// If the class is generic we must use the generic type definition.
MonoClass *klass = mono_class;
MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), get_mono_type());
if (GDMonoUtils::Marshal::type_is_generic(reftype)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this helper function. You should be able to do the same with mono_type_get_type(this->get_mono_type()) == MONO_TYPE_GENERICINST, but I haven't tested.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, so I changed it.

If the class is generic, we must get its generic type definition and use
it to retrieve the delegates.
@raulsntos raulsntos force-pushed the csharp-delegates-for-generic-class branch from b45990d to d28be4d Compare December 4, 2021 01:56
@neikeq neikeq merged commit 2a9dd65 into godotengine:master Dec 4, 2021
@neikeq
Copy link
Contributor

neikeq commented Dec 4, 2021

Thanks!

@raulsntos raulsntos deleted the csharp-delegates-for-generic-class branch December 4, 2021 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use signal declared in abstract generic class
3 participants