summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-03-04 02:25:37 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-03-04 02:25:37 -0500
commitd0b66b13bd828f81048074f442653f5467b9b18f (patch)
treed3015aa25b960cb1f40c69a6cbf4ac08e5065deb /src
parent9a9622702ab310261ebedd5e0310f5f40f6812a1 (diff)
downloadSMAPI-d0b66b13bd828f81048074f442653f5467b9b18f.tar.gz
SMAPI-d0b66b13bd828f81048074f442653f5467b9b18f.tar.bz2
SMAPI-d0b66b13bd828f81048074f442653f5467b9b18f.zip
fix false broken-code detection when referencing a generic type (#453)
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs
index 2aee7af4..0e7344a8 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs
@@ -48,6 +48,10 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
if (fieldRef != null)
{
+ // can't compare generic type parameters between definition and reference
+ if (fieldRef.FieldType.IsGenericInstance || fieldRef.FieldType.IsGenericParameter)
+ return InstructionHandleResult.None;
+
// get target field
FieldDefinition targetField = fieldRef.DeclaringType.Resolve()?.Fields.FirstOrDefault(p => p.Name == fieldRef.Name);
if (targetField == null)
@@ -67,6 +71,10 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
MethodReference methodReference = RewriteHelper.AsMethodReference(instruction);
if (methodReference != null)
{
+ // can't compare generic type parameters between definition and reference
+ if (methodReference.ReturnType.IsGenericInstance || methodReference.ReturnType.IsGenericParameter)
+ return InstructionHandleResult.None;
+
// get potential targets
MethodDefinition[] candidateMethods = methodReference.DeclaringType.Resolve()?.Methods.Where(found => found.Name == methodReference.Name).ToArray();
if (candidateMethods == null || !candidateMethods.Any())