Prevent Binary Operation functions from being garbage collected

This commit is contained in:
Deukhoofd 2019-09-12 16:59:16 +02:00
parent e44432c068
commit c3f1a00750
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 3 additions and 0 deletions

View File

@ -15,6 +15,8 @@ namespace PorygonSharp.UserData
public Type Type { get; }
private readonly Dictionary<Type, MethodInfo> _implicitCasts;
private readonly Dictionary<Type, MethodInfo> _explicitCasts;
// ReSharper disable once CollectionNeverQueried.Local
private readonly List<UserDataBinaryOperation> _binaryOperations = new List<UserDataBinaryOperation>();
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)]