C# GetGodotPropertyList() -- "Do not call this method". Why?

Godot Version

v4.2.1.stable.mono.official [b09f793f5]


I’m using ˙protobuf-net for game state persistence, which requires registering custom classes, and this includes having to list the property names I wish to include.

For Godot’s `Vector3 this is what I need to do:

RuntimeTypeModel.Default.Add(typeof(Vector3), false).Add("X", "Y", "Z");

Thankfully, the .Add method also accepts a string[], so for my more complex classes I can collect the property names like so:

RuntimeTypeModel.Default.Add(typeof(MyClass)).Add(MyClass.GetGodotPropertyList().Select(p => p.Name.ToString()).ToArray());

This works, but an ominous warning concludes the documentation of the GetGodotPropertyList method: “Do not call this method.”


If it’d awake and invoke the Great Cthulhu (and we obviously don’t want that), how would I collect the property names of my classes?

c# has refection. the example below isn’t all inclusive but should give you an idea

using Godot;
using System;

public partial class test:Node2D {
	void MyTest(System.Type a_type) {
		string v_properties = "Properties:";
		foreach(System.Reflection.PropertyInfo j_item in a_type.GetProperties()) {
			v_properties += j_item.Name + " ";
		string v_members = "Members:";
		foreach(System.Reflection.MemberInfo j_item in a_type.GetMembers()) {
			v_members += j_item.Name + " ";
		GD.Print(v_properties, v_members);

	public override void _Ready() {

1 Like

Thank you for the suggestion, although I’m still curious as to why we must avoid the GetGodotPropertyList method. :slight_smile:

Anyway, the code below seems to return the same collection as the forbidden one, if anyone is interested:

foreach (var memberInfo in aType.GetFields(BindingFlags.Instance | BindingFlags.Public))
1 Like

This is a method generated, and used by Godot internals. There is no danger to calling it, but it should not be considered as part of the accessible API. As such, there is for instance no guarantee this method will exist in future versions of Godot, or that backward-compatibility won’t be broken for this method, etc. That is why it is hidden with EditorBrowsableState.Never, and hinted as “Do not call”.

1 Like