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

Godot Version

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

Question

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.”

Why?

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?

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

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.