You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears nesting classes too deeply in a file breaks the code generator on C# projects (unsure if this is applicable to GDScript).
Problem Description
If you have a single file with deeply nested classes, the code generator can fail to build.
See reproduction steps for an example of what breaks it, as well as the log messages.
Expected Behavior
Ideally, you should be able to nest resources arbitrarily. Oftentimes, the reason a class is nested is because it will never be used elsewhere. The source generator should not care about the structure of my code, as long as it is valid code.
If this is something that should not be allowed, I would at the very least expect a build error message that conveys that. The errors does not make it clear what actionable steps can be taken to resolve the issue.
Workaround
Currently the only way to pass the build is to refactor files so that there is no more than one level of nesting.
That said, I find that approach can lead to cluttering namespaces or needing to write more verbose names.
It should fail with the following errors (... is meant to represent the project root dir):
D:\...\Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\Foo.Bar.Baz_ScriptProperties.generated.cs(15,29): error CS0115: 'Bar.Foo.Baz.SetGodotClassPropertyValue(in godot_string_name, in godot_variant)': no suitable method found to override [D:\...\Example.csproj]
D:\...\Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\Foo.Bar.Baz_ScriptProperties.generated.cs(27,29): error CS0115: 'Bar.Foo.Baz.GetGodotClassPropertyValue(in godot_string_name, out godot_variant)': no suitable method found to override [D:\...\Example.csproj]
D:\...\Godot.SourceGenerators\Godot.SourceGenerators.ScriptSerializationGenerator\Foo.Bar.Baz_ScriptSerialization.generated.cs(10,29): error CS0115: 'Bar.Foo.Baz.SaveGodotObjectData(GodotSerializationInfo)': no suitable method found to override [D:\...\Example.csproj]
D:\...\Godot.SourceGenerators\Godot.SourceGenerators.ScriptSerializationGenerator\Foo.Bar.Baz_ScriptSerialization.generated.cs(16,29): error CS0115: 'Bar.Foo.Baz.RestoreGodotObjectData(GodotSerializationInfo)': no suitable method found to override [D:\...\Example.csproj]
However, if you remove Foo, and simply nest once, this error does not occur despite the logic not changing.
Here's an example project. It really doesn't have anything except the script in the reproduction steps. Example.zip
The text was updated successfully, but these errors were encountered:
donovani
changed the title
C# code generation breaks on resources with >2 levels of nested Resources
C# code generation breaks on Resources with >2 levels of nesting
Oct 11, 2023
That said, nested classes can't be used as scripts. Script classes must be a top-level class and its name must match the name of the file where they are declared.
Godot version
4.1.1
System information
Godot v4.1.1.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz (8 Threads)
Issue description
It appears nesting classes too deeply in a file breaks the code generator on C# projects (unsure if this is applicable to GDScript).
Problem Description
If you have a single file with deeply nested classes, the code generator can fail to build.
See reproduction steps for an example of what breaks it, as well as the log messages.
Expected Behavior
Ideally, you should be able to nest resources arbitrarily. Oftentimes, the reason a class is nested is because it will never be used elsewhere. The source generator should not care about the structure of my code, as long as it is valid code.
If this is something that should not be allowed, I would at the very least expect a build error message that conveys that. The errors does not make it clear what actionable steps can be taken to resolve the issue.
Workaround
Currently the only way to pass the build is to refactor files so that there is no more than one level of nesting.
That said, I find that approach can lead to cluttering namespaces or needing to write more verbose names.
Steps to reproduce
Attempt to build the following Resource:
It should fail with the following errors (
...
is meant to represent the project root dir):However, if you remove Foo, and simply nest once, this error does not occur despite the logic not changing.
Minimal reproduction project
Here's an example project. It really doesn't have anything except the script in the reproduction steps.
Example.zip
The text was updated successfully, but these errors were encountered: