1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Merge pull request #96955 from Delsin-Yu/generator-based-CreateManagedForGodotObjectBinding

[.NET] Replace Reflection-Based implementation with Generated one in `CreateManagedForGodotObjectBinding`
This commit is contained in:
Rémi Verschelde
2024-09-23 16:13:49 +02:00
4 changed files with 158 additions and 74 deletions

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using GodotTools.Build;
using GodotTools.Ides;
using GodotTools.Ides.Rider;
@@ -701,6 +702,23 @@ namespace GodotTools
private static IntPtr InternalCreateInstance(IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
{
Internal.Initialize(unmanagedCallbacks, unmanagedCallbacksSize);
var populateConstructorMethod =
AppDomain.CurrentDomain
.GetAssemblies()
.First(x => x.GetName().Name == "GodotSharpEditor")
.GetType("Godot.EditorConstructors")?
.GetMethod("AddEditorConstructors",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (populateConstructorMethod == null)
{
throw new MissingMethodException("Godot.EditorConstructors",
"AddEditorConstructors");
}
populateConstructorMethod.Invoke(null, null);
return new GodotSharpEditor().NativeInstance;
}
}