-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Godot ignores namespace information when instantiating C# classes #17409
Comments
It's a prerequisite to #15661, and probably also to #15237. In #15237, I thought it just doesn't handle namespace informations correctly just for addon projects, but it seems like Godot relies soley on a class name derived from a source path, ignoring both the assembly and namespace information for all cases. |
From what I discussed with @neikeq , obtaining the actual class from the file with a tag should be easy. Either using roslyn of with a hand made parser (tokenizing C# is super easy) |
I agree that probably parsing the source file could be the easiest way to solve this problem for now. (It wouldn't support declaring more than one classes in a single source file, but maybe it's a corner case.) @reduz I'm sorry I've dragged you around on many different issues. I initially thought this should have a more impact on the original issue, but now I realized the worst scenario wouldn't be more than simply abandoning the suggested parser code, which probably is not much of a loss. So, I think it'd be better to fix this issue in a way that can be done with the minimal efforts, and continue to discuss if all related cases like #15237 can be supported using the current source based approach later. |
Yes, this is a known limitation that will be fixed soon. I was waiting to finish the exporter in order to implement this. The way Godot will detect the qualified name for the script is the following:
|
@neikeq what's the status of this issue? Just tested and it looks like it grabs the last class w/ the same name in the item group and executes it. <ItemGroup>
<Compile Include="Namespace1\MyClass.cs" />
<Compile Include="Namespace2\MyClass.cs" />
<Compile Include="Namespace3\MyClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> This could be a huge issue with larger projects and could put off a lot of people wanting to use the c# godot version, as this is a show stopper. |
Godot version:
master
/ dad47d8OS/device including version:
Manjaro 17.1
Issue description:
Godot apparently doesn't take the namespace information into account when instantiating a class that is assigned to a node.
Steps to reproduce:
Namespace2/MyClass.cs
and assign it to a node.Namespace2.MyClass._Ready()
and addGD.Print("MyClass 2")
.MyClass 2
is printed in the console.Namespace1/MyClass.cs
but do not assign it to anything.Namespace1.MyClass._Ready()
and addGD.Print("MyClass 1")
.MyClass 1
is printed instead ofMyClass 2
.The text was updated successfully, but these errors were encountered: