浏览代码

Merge pull request #95431 from Joy-less/Fix-#10418

C#: Add `NotNullWhenAttribute` to `IsInstanceValid`
Rémi Verschelde 1 年之前
父节点
当前提交
c98d549e65
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/GodotObjectExtensions.cs

+ 2 - 1
modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/GodotObjectExtensions.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics.CodeAnalysis;
 using Godot.NativeInterop;
 
 #nullable enable
@@ -51,7 +52,7 @@ namespace Godot
         /// </summary>
         /// <param name="instance">The instance to check.</param>
         /// <returns>If the instance is a valid object.</returns>
-        public static bool IsInstanceValid(GodotObject? instance)
+        public static bool IsInstanceValid([NotNullWhen(true)] GodotObject? instance)
         {
             return instance != null && instance.NativeInstance != IntPtr.Zero;
         }