-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
.NET 6 C# - ScriptPropertiesGenerator fail with overridden initialized property on master #71102
Comments
I didn't consider that there may be non-readonly properties with a null SetMethod. #71128 should fix it. |
[Context: This bug is so elusive and hard to catch, that I cannot reproduce it reliably enough to isolate a proper issue. Here's a way it happened to me if it helps anyone. Using Godot 4.3-stable and a self-compiled build of 4.3-stable with PR #79731 baked in. Both of them worked the same. This makes it C#/Mono exclusive.] The one thing that triggered this bug is this asset from the Asset Library. It's not the asset itself that causes this. This bug happened unexpectedly (while on a game jam), even if under the same conditions it worked before. The conditions were:
The only solution was:
It might've been a game-breaker for many. Some steps might look unnecessary but they were in this particular case. The game was so tainted by several days of having this time bomb lurking that I did lose some code, and thankfully I did have some working backups to fall back into. I did find a comment on the ScriptPropertyDefValGenerator.cs file that kind of makes me think of something. I am not a professional C# programmer, nor expert in the field, but I did find a pattern:
I write this after quite a while of figuring out the details of this bug... but I cannot reproduce them 100% reliably, mainly because the aforementioned evasive nature of it. But my gut feeling is that it's not resolving this specific combination of abstraction correctly, and that, worst case, we should get a warning this pattern is not recommended and can cause later harm. |
Godot version
v4.0.beta.mono.custom_build [56522f7] (with double)
System information
Arch Linux, Vulkan
Issue description
C# projects with a parent class including a virtual property that is then overridden & initialized in a child class appear to cause ScriptPropertiesGenerator & ScriptSerializationGenerator to fail to generate source.
The problem appears to be caused by #70483, the Source Generators run fine if built immediately before this PR was committed.
I'm not sure how to debug the Source Generators for a more useful error/stack trace than below, sorry.
Parent Class
Child Class
If the initialized property override below is commented then the Source Generators work fine.
Warnings/Errors produced
Warnings produced when a child class overrides the initialized property from its parent:
Any
[Export]
properties then throw build errors as ScriptPropertiesGenerator failed:Steps to reproduce
Build the solution in the minimal reproduction project.
Minimal reproduction project
csharpbug_03c26d6.zip
The text was updated successfully, but these errors were encountered: