fix AccessTools facade constructor logic (#711)

This commit is contained in:
Jesse Plamondon-Willard 2020-05-21 22:21:24 -04:00
parent f8e0600672
commit 7fdc3a2ab2
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
1 changed files with 12 additions and 3 deletions

View File

@ -16,17 +16,26 @@ namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades
*********/
public static ConstructorInfo DeclaredConstructor(Type type, Type[] parameters = null)
{
return AccessTools.DeclaredConstructor(type, parameters, searchForStatic: true);
// Harmony 1.x matched both static and instance constructors
return
AccessTools.DeclaredConstructor(type, parameters, searchForStatic: false)
?? AccessTools.DeclaredConstructor(type, parameters, searchForStatic: true);
}
public static ConstructorInfo Constructor(Type type, Type[] parameters = null)
{
return AccessTools.Constructor(type, parameters, searchForStatic: true);
// Harmony 1.x matched both static and instance constructors
return
AccessTools.Constructor(type, parameters, searchForStatic: false)
?? AccessTools.Constructor(type, parameters, searchForStatic: true);
}
public static List<ConstructorInfo> GetDeclaredConstructors(Type type)
{
return AccessTools.GetDeclaredConstructors(type, searchForStatic: true);
// Harmony 1.x matched both static and instance constructors
return
AccessTools.GetDeclaredConstructors(type, searchForStatic: false)
?? AccessTools.GetDeclaredConstructors(type, searchForStatic: true);
}
}
}