summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SMAPI/Framework/Reflection/PrivateProperty.cs6
1 files changed, 4 insertions, 2 deletions
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<object, TValue>)Delegate.CreateDelegate(typeof(Func<object, TValue>), this.PropertyInfo.GetMethod);
- this.SetterDelegate = (Action<object, TValue>)Delegate.CreateDelegate(typeof(Action<object, TValue>), this.PropertyInfo.SetMethod);
+ Type[] types = new Type[] { this.PropertyInfo.DeclaringType, typeof(TValue)};
+
+ this.GetterDelegate = (Func<object, TValue>)Delegate.CreateDelegate(typeof(Func<,>).MakeGenericType(types), this.PropertyInfo.GetMethod);
+ this.SetterDelegate = (Action<object, TValue>)Delegate.CreateDelegate(typeof(Action<,>).MakeGenericType(types), this.PropertyInfo.SetMethod);
}
/// <summary>Get the property value.</summary>