godotengine / godotengine/godot

[C#] Class with GlobalClass attribute and that inherits from base class from another assembly is not listed in the Create New Node dialog

Open
#95,036 7 comments 6 reactions 0 assignees View on GitHub
bug topic:dotnet
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.3-rc.1
4.3-beta.3
4.2.2-stable

### System information

Windows 10

### Issue description

I have one assembly containing classes I want to reuse for various Godot projects (e.g. player script, inventory script, etc.).
This assembly use `Godot.NET.Sdk/`.
In a new Godot project, I add a reference to the said assembly. Then, I create a new class that inherits from one of the classes exposed by this assembly.
I add the `GlobalClass` attribute to my new class in order to see it listed by the Create New Node dialog.

**Expected behavior:**

The class is listed by the Create New Node dialog.
This is the case for Godot 4.2.2 as shown in the screenshot below:
![image](https://github.com/user-attachments/assets/0c39a23b-e50c-44a6-bb5b-9bda79172d71)

**Current behavior:**

The class is no longer listed by the Create New Node dialog.
This is the case for Godot 4.3 beta.3 and rc.1.
The following error is logged:
```
editor/create_dialog.cpp:272 - Condition "inherits == StringName()" is true.
```

### Steps to reproduce

1. Create a new C# project and edit the `csproj` file to use `Godot.NET.Sdk/`.
2. Create a new class that inherits from `Node` for example. Make it `public`.
3. Build the project.
4. Create a new Godot project, then create the C# solution.
5. Open the project, right click on `Dependencies` > `Add project reference...` > `Browse...` > add the assembly DLL.
6. Create a new class that inherits from the class previously created in the assembly. Add the `GlobalClass` attribute.
7. Build the project, then open the Create New Node dialog.

### Minimal reproduction project (MRP)

The following MRP is the almost ready version of the reproduction steps.
The external assembly is named `MyAssembly`.
You have two build configurations: one for Godot 4.2.2, one for Godot 4.3-rc.1.

Make sure to test the 4.2.2 version first by building the assembly with the corresponding configuration.
Then open the Godot project with Godot 4.2.2. In the C# project, add a reference to the assembly, then build the project. If everything went well, `MyCustomGlobalClass` should show up.

Then, build the 4.3 version of the assembly.
Open the Godot project with Godot 4.3 and upgrade it. In the C# project, update the assembly reference, then build the project again.

[MRP.zip](https://github.com/user-attachments/files/16461196/MRP.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.