C#: Document generated members

Documents generated members and tries to discourage users from calling/overriding internal methods that only exist to be used by the engine.
This commit is contained in:
Raul Santos 2023-07-09 14:14:36 +02:00
parent 83cc5d4914
commit 12e4aa93b3
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
8 changed files with 195 additions and 14 deletions

View file

@ -135,6 +135,10 @@ namespace Godot.SourceGenerators
source.Append("#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword\n");
source.Append(" /// <summary>\n")
.Append(" /// Cached StringNames for the methods contained in this class, for fast lookup.\n")
.Append(" /// </summary>\n");
source.Append(
$" public new class MethodName : {symbol.BaseType.FullQualifiedNameIncludeGlobal()}.MethodName {{\n");
@ -147,6 +151,12 @@ namespace Godot.SourceGenerators
foreach (string methodName in distinctMethodNames)
{
source.Append(" /// <summary>\n")
.Append(" /// Cached name for the '")
.Append(methodName)
.Append("' method.\n")
.Append(" /// </summary>\n");
source.Append(" public new static readonly global::Godot.StringName ");
source.Append(methodName);
source.Append(" = \"");
@ -162,6 +172,14 @@ namespace Godot.SourceGenerators
{
const string listType = "global::System.Collections.Generic.List<global::Godot.Bridge.MethodInfo>";
source.Append(" /// <summary>\n")
.Append(" /// Get the method information for all the methods declared in this class.\n")
.Append(" /// This method is used by Godot to register the available methods in the editor.\n")
.Append(" /// Do not call this method.\n")
.Append(" /// </summary>\n");
source.Append(" [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]\n");
source.Append(" internal new static ")
.Append(listType)
.Append(" GetGodotMethodList()\n {\n");
@ -188,6 +206,8 @@ namespace Godot.SourceGenerators
if (godotClassMethods.Length > 0)
{
source.Append(" /// <inheritdoc/>\n");
source.Append(" [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]\n");
source.Append(" protected override bool InvokeGodotClassMethod(in godot_string_name method, ");
source.Append("NativeVariantPtrArgs args, out godot_variant ret)\n {\n");
@ -205,6 +225,8 @@ namespace Godot.SourceGenerators
if (distinctMethodNames.Length > 0)
{
source.Append(" /// <inheritdoc/>\n");
source.Append(" [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]\n");
source.Append(" protected override bool HasGodotClassMethod(in godot_string_name method)\n {\n");
bool isFirstEntry = true;