Merge pull request #83217 from paulloz/fix/81903-delegate-capture-serialization

[.NET] Fix serialization of delegates capturing variables
This commit is contained in:
Rémi Verschelde 2024-04-05 12:15:36 +02:00
commit 72f9f8d339
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 5 deletions

View File

@ -207,7 +207,7 @@ namespace Godot
foreach (FieldInfo field in fields)
{
Type fieldType = field.GetType();
Type fieldType = field.FieldType;
Variant.Type variantType = GD.TypeToVariantType(fieldType);
@ -216,7 +216,7 @@ namespace Godot
static byte[] VarToBytes(in godot_variant var)
{
NativeFuncs.godotsharp_var_to_bytes(var, false.ToGodotBool(), out var varBytes);
NativeFuncs.godotsharp_var_to_bytes(var, godot_bool.True, out var varBytes);
using (varBytes)
return Marshaling.ConvertNativePackedByteArrayToSystemArray(varBytes);
}
@ -483,7 +483,7 @@ namespace Godot
if (fieldInfo != null)
{
var variantValue = GD.BytesToVar(valueBuffer);
var variantValue = GD.BytesToVarWithObjects(valueBuffer);
object? managedValue = RuntimeTypeConversionHelper.ConvertToObjectOfType(
(godot_variant)variantValue.NativeVar, fieldInfo.FieldType);
fieldInfo.SetValue(recreatedTarget, managedValue);
@ -799,7 +799,7 @@ namespace Godot
return func(variant);
if (typeof(GodotObject).IsAssignableFrom(type))
return Convert.ChangeType(VariantUtils.ConvertTo<GodotObject>(variant), type, CultureInfo.InvariantCulture);
return VariantUtils.ConvertTo<GodotObject>(variant);
if (typeof(GodotObject[]).IsAssignableFrom(type))
{
@ -818,7 +818,7 @@ namespace Godot
}
using var godotArray = NativeFuncs.godotsharp_variant_as_array(variant);
return Convert.ChangeType(ConvertToSystemArrayOfGodotObject(godotArray, type), type, CultureInfo.InvariantCulture);
return ConvertToSystemArrayOfGodotObject(godotArray, type);
}
if (type.IsEnum)