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

C#: Fix generator crash w/ generic arrays #91375

Conversation

paulloz
Copy link
Member

@paulloz paulloz commented Apr 30, 2024

✌️

Currently, the following code will throw the ScriptPropertiesGenerator in a CSC error, and prevent further compilation. This is because we are trying to find a valid type hint for the export, on a generic that is not yet constructed. Note that doing the same thing with a Godot.Collection.Dictionary<T1, T2> is not causing any issue, since we do not try to find type hints for dictionaries.

public abstract partial class Foo<[MustBeVariant] T> : Node
{
    [Export]
    private Godot.Collections.Array<T> collection = new();
}

To prevent the error, I think we can simply elect to not look for type hints here. I still need to go through #83432, if we want a better behaviour when it comes to generics. But in the meantime, not crashing is IMHO a priority.

@paulloz paulloz requested a review from a team as a code owner April 30, 2024 20:29
@paulloz paulloz added this to the 4.3 milestone Apr 30, 2024
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@akien-mga akien-mga merged commit 4eaafc8 into godotengine:master May 2, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@paulloz paulloz deleted the dotnet/prevent-generator-crash-on-exported-unconstructed-generic-arrays branch May 4, 2024 15:49
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.

3 participants