diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index c7636898c165..1f969e4b7edd 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -1052,7 +1052,7 @@ public sealed class Array<[MustBeVariant] T> : IEnumerable, IGenericGodotArray { - private static godot_variant ToVariantFunc(in Array godotArray) => + private static godot_variant ToVariantFunc(scoped in Array godotArray) => VariantUtils.CreateFromArray(godotArray); private static Array FromVariantFunc(in godot_variant variant) => @@ -1060,8 +1060,8 @@ private static Array FromVariantFunc(in godot_variant variant) => static unsafe Array() { - VariantUtils.GenericConversion>.ToVariantCb = &ToVariantFunc; - VariantUtils.GenericConversion>.FromVariantCb = &FromVariantFunc; + VariantUtils.GenericConversion>.ToVariantCb = ToVariantFunc; + VariantUtils.GenericConversion>.FromVariantCb = FromVariantFunc; } private readonly Array _underlyingArray; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs index 43cc5b63dd00..34d2182336c9 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs @@ -490,7 +490,7 @@ public class Dictionary<[MustBeVariant] TKey, [MustBeVariant] TValue> : IReadOnlyDictionary, IGenericGodotDictionary { - private static godot_variant ToVariantFunc(in Dictionary godotDictionary) => + private static godot_variant ToVariantFunc(scoped in Dictionary godotDictionary) => VariantUtils.CreateFromDictionary(godotDictionary); private static Dictionary FromVariantFunc(in godot_variant variant) => @@ -498,8 +498,8 @@ private static Dictionary FromVariantFunc(in godot_variant variant static unsafe Dictionary() { - VariantUtils.GenericConversion>.ToVariantCb = &ToVariantFunc; - VariantUtils.GenericConversion>.FromVariantCb = &FromVariantFunc; + VariantUtils.GenericConversion>.ToVariantCb = ToVariantFunc; + VariantUtils.GenericConversion>.FromVariantCb = FromVariantFunc; } private readonly Dictionary _underlyingDict; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs index a7819f8ba27a..d8c8ea568fd6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs @@ -12,19 +12,18 @@ public partial class VariantUtils internal static class GenericConversion { + internal delegate godot_variant ToVariantConverter(scoped in T from); + internal delegate T FromVariantConverter(in godot_variant from); + public static unsafe godot_variant ToVariant(scoped in T from) => -#pragma warning disable CS9088 // the delegate pointer cannot be marked scoped, but it should be - ToVariantCb != null ? ToVariantCb(from) : throw UnsupportedType(); -#pragma warning restore CS9088 + ToVariantCb != null ? ToVariantCb(from) : throw UnsupportedType(); public static unsafe T FromVariant(in godot_variant variant) => FromVariantCb != null ? FromVariantCb(variant) : throw UnsupportedType(); - // ReSharper disable once StaticMemberInGenericType - internal static unsafe delegate* ToVariantCb; + internal static ToVariantConverter? ToVariantCb; - // ReSharper disable once StaticMemberInGenericType - internal static unsafe delegate* FromVariantCb; + internal static FromVariantConverter? FromVariantCb; static GenericConversion() {