fix false broken-code detection when referencing a generic type (#453)
This commit is contained in:
parent
9a9622702a
commit
d0b66b13bd
|
@ -48,6 +48,10 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
|
||||||
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
|
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
|
||||||
if (fieldRef != null)
|
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
|
// get target field
|
||||||
FieldDefinition targetField = fieldRef.DeclaringType.Resolve()?.Fields.FirstOrDefault(p => p.Name == fieldRef.Name);
|
FieldDefinition targetField = fieldRef.DeclaringType.Resolve()?.Fields.FirstOrDefault(p => p.Name == fieldRef.Name);
|
||||||
if (targetField == null)
|
if (targetField == null)
|
||||||
|
@ -67,6 +71,10 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
|
||||||
MethodReference methodReference = RewriteHelper.AsMethodReference(instruction);
|
MethodReference methodReference = RewriteHelper.AsMethodReference(instruction);
|
||||||
if (methodReference != null)
|
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
|
// get potential targets
|
||||||
MethodDefinition[] candidateMethods = methodReference.DeclaringType.Resolve()?.Methods.Where(found => found.Name == methodReference.Name).ToArray();
|
MethodDefinition[] candidateMethods = methodReference.DeclaringType.Resolve()?.Methods.Where(found => found.Name == methodReference.Name).ToArray();
|
||||||
if (candidateMethods == null || !candidateMethods.Any())
|
if (candidateMethods == null || !candidateMethods.Any())
|
||||||
|
|
Loading…
Reference in New Issue