From c3f1a00750ae8187a73b37f0f27b5e300d056a13 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 12 Sep 2019 16:59:16 +0200 Subject: [PATCH] Prevent Binary Operation functions from being garbage collected --- PorygonSharp/UserData/UserData.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PorygonSharp/UserData/UserData.cs b/PorygonSharp/UserData/UserData.cs index 875753d..81b2e85 100644 --- a/PorygonSharp/UserData/UserData.cs +++ b/PorygonSharp/UserData/UserData.cs @@ -15,6 +15,8 @@ namespace PorygonSharp.UserData public Type Type { get; } private readonly Dictionary _implicitCasts; private readonly Dictionary _explicitCasts; + // ReSharper disable once CollectionNeverQueried.Local + private readonly List _binaryOperations = new List(); private delegate bool IsCastableDelegate(IntPtr scriptType, bool isExplicit); private delegate IntPtr CastDelegate(IntPtr obj, IntPtr scriptType); @@ -216,6 +218,7 @@ namespace PorygonSharp.UserData { var operation = UserDataBinaryOperation.Create(info); AddUserdataBinaryOperation(Id, (byte)kind, operation.Handle); + _binaryOperations.Add(operation); } [DllImport("PorygonLang", EntryPoint = "RegisterUserDataField", CallingConvention = CallingConvention.Cdecl)]