diff options
author | Entoarox <kvdk@kvdk.net> | 2017-10-13 19:00:55 +0200 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-24 20:18:23 -0400 |
commit | 191d65f8d9e90cc3a9788afcae852f8879962428 (patch) | |
tree | 9a2effa7ee31debad37b738981da50686ebe4a0b /src/SMAPI/Framework/Reflection/PrivateProperty.cs | |
parent | ded647aad41d8e3591a21bdd6aa6503273312a27 (diff) | |
download | SMAPI-191d65f8d9e90cc3a9788afcae852f8879962428.tar.gz SMAPI-191d65f8d9e90cc3a9788afcae852f8879962428.tar.bz2 SMAPI-191d65f8d9e90cc3a9788afcae852f8879962428.zip |
Fix: Instance type is required
Diffstat (limited to 'src/SMAPI/Framework/Reflection/PrivateProperty.cs')
-rw-r--r-- | src/SMAPI/Framework/Reflection/PrivateProperty.cs | 6 |
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> |