From fd160b642e7ac143496b801a69193138feb01857 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Sun, 10 Oct 2021 11:40:53 +0200 Subject: [PATCH] Fix C# List marshalling --- modules/mono/mono_gd/gd_mono_marshal.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 40c6b4ed656..d8a69179af1 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -982,16 +982,19 @@ Dictionary system_generic_dict_to_Dictionary(MonoObject *p_obj, GDMonoClass *p_c } MonoObject *Array_to_system_generic_list(const Array &p_array, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype) { - GDMonoClass *elem_class = ManagedType::from_reftype(p_elem_reftype).type_class; + MonoType *elem_type = mono_reflection_type_get_type(p_elem_reftype); - String ctor_desc = ":.ctor(System.Collections.Generic.IEnumerable`1<" + elem_class->get_type_desc() + ">)"; + String ctor_desc = ":.ctor(System.Collections.Generic.IEnumerable`1<" + GDMonoUtils::get_type_desc(elem_type) + ">)"; GDMonoMethod *ctor = p_class->get_method_with_desc(ctor_desc, true); CRASH_COND(ctor == nullptr); MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); ERR_FAIL_NULL_V(mono_object, nullptr); - void *ctor_args[1] = { Array_to_mono_array(p_array, elem_class) }; + GDMonoClass *godot_array_class = GDMonoUtils::Marshal::make_generic_array_type(p_elem_reftype); + MonoObject *godot_array = GDMonoUtils::create_managed_from(p_array, godot_array_class); + + void *ctor_args[1] = { godot_array }; MonoException *exc = nullptr; ctor->invoke_raw(mono_object, ctor_args, &exc);