Skip to content

Commit f0ec392

Browse files
committed
[.Net] Avoid StringName allocations if type does not defines _Get or _Set
1 parent 594d64e commit f0ec392

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ internal static unsafe godot_bool Set(IntPtr godotObjectGCHandle, godot_string_n
5959
return godot_bool.True;
6060
}
6161

62+
if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Set.NativeValue.DangerousSelfRef))
63+
{
64+
return godot_bool.False;
65+
}
66+
6267
var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
6368
NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
6469

@@ -107,6 +112,11 @@ internal static unsafe godot_bool Get(IntPtr godotObjectGCHandle, godot_string_n
107112
return godot_bool.True;
108113
}
109114

115+
if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Get.NativeValue.DangerousSelfRef))
116+
{
117+
return godot_bool.False;
118+
}
119+
110120
var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
111121
NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
112122

0 commit comments

Comments
 (0)