From 191d65f8d9e90cc3a9788afcae852f8879962428 Mon Sep 17 00:00:00 2001 From: Entoarox Date: Fri, 13 Oct 2017 19:00:55 +0200 Subject: Fix: Instance type is required --- src/SMAPI/Framework/Reflection/PrivateProperty.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/SMAPI/Framework/Reflection/PrivateProperty.cs') diff --git a/src/SMAPI/Framework/Reflection/PrivateProperty.cs b/src/SMAPI/Framework/Reflection/PrivateProperty.cs index 8a75d925..718594ee 100644 --- a/src/SMAPI/Framework/Reflection/PrivateProperty.cs +++ b/src/SMAPI/Framework/Reflection/PrivateProperty.cs @@ -51,8 +51,10 @@ namespace StardewModdingAPI.Framework.Reflection this.Parent = obj; this.PropertyInfo = property ?? throw new ArgumentNullException(nameof(property)); - this.GetterDelegate = (Func)Delegate.CreateDelegate(typeof(Func), this.PropertyInfo.GetMethod); - this.SetterDelegate = (Action)Delegate.CreateDelegate(typeof(Action), this.PropertyInfo.SetMethod); + Type[] types = new Type[] { this.PropertyInfo.DeclaringType, typeof(TValue)}; + + this.GetterDelegate = (Func)Delegate.CreateDelegate(typeof(Func<,>).MakeGenericType(types), this.PropertyInfo.GetMethod); + this.SetterDelegate = (Action)Delegate.CreateDelegate(typeof(Action<,>).MakeGenericType(types), this.PropertyInfo.SetMethod); } /// Get the property value. -- cgit