c# version build failed

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By qdmyxwlhx

l convert all my project from gdscript to c#. l complete the work and the editor have no error prompt. But when l build(use button ‘build’ in godot editor), it failed and show info like:

 /Users/zyb/a/GodotProject/tw_cs/src/character/chtr.cs(7,1): error GD0001: Missing partial modifier on declaration of type 'Chtr' which is a subclass of 'Godot.GodotObject' [/Users/zyb/a/GodotProject/tw_cs/tw_cs.csproj]
        
 /Users/zyb/a/GodotProject/tw_cs/src/character/Sprite2d.cs(3,1): error GD0001: Missing partial modifier on declaration of type 'Sprite2d' which is a subclass of 'Godot.GodotObject' [/Users/zyb/a/GodotProject/tw_cs/tw_cs.csproj]
        
 /Users/zyb/a/GodotProject/tw_cs/src/DataManager.cs(12,1): error GD0001: Missing partial modifier on declaration of type 'DataManager' which is a subclass of 'Godot.GodotObject' [/Users/zyb/a/GodotProject/tw_cs/tw_cs.csproj]
         
/Users/zyb/a/GodotProject/tw_cs/src/Models/Models.cs(8,5): error GD0001: Missing partial modifier on declaration of type 'TileWorld.Core.Models.CraftCount' which is a subclass of 'Godot.GodotObject' [/Users/zyb/a/GodotProject/tw_cs/tw_cs.csproj]

there are another 10 error info like this, the difference is the class name. Seems like all my class have some problem.

This problem annoying me a lot of days, please anyone help me

Animal welfare is not just about preventing animal cruelty, it’s also about promoting the well-being of animals in all aspects of their lives. This includes providing them with proper nutrition, shelter, and medical care. Please checkout: Animal Welfare

kitticpet | 2023-03-11 07:05

:bust_in_silhouette: Reply From: jgodfrey

Sounds like you haven’t added partial to your class definitions.

So, instead of something like this:

public class MyClass : Sprite2D

You want:

public partial class MyClass : Sprite2D

is there another solution? my class do not need partial in logic, and the c# editor haven’t say it need partial.

all class need partial is nonsense.

qdmyxwlhx | 2023-03-10 02:39

Does that fix the problem?

jgodfrey | 2023-03-10 02:49

lt works. is this the rule of godot c#? l add ‘partial’ before every class in my project.

qdmyxwlhx | 2023-03-10 03:27

:bust_in_silhouette: Reply From: qdmyxwlhx

l find out why l need ‘partial’ before class.