소스 검색

[.Net] Avoid StringName allocations if type does not defines `_Get` or `_Set`

DE-YU_H14 5 달 전
부모
커밋
f0ec392bb1
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs

+ 10 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs

@@ -59,6 +59,11 @@ namespace Godot.Bridge
                     return godot_bool.True;
                 }
 
+                if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Set.NativeValue.DangerousSelfRef))
+                {
+                    return godot_bool.False;
+                }
+
                 var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
                     NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
 
@@ -107,6 +112,11 @@ namespace Godot.Bridge
                     return godot_bool.True;
                 }
 
+                if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Get.NativeValue.DangerousSelfRef))
+                {
+                    return godot_bool.False;
+                }
+
                 var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
                     NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));