Skip to content

Commit

Permalink
Merge pull request #639 from Banane9/fix/wrong-original-method-#638
Browse files Browse the repository at this point in the history
Fix #638 by preventing the NullReferenceException
  • Loading branch information
pardeike authored Dec 17, 2024
2 parents f957040 + ea661ef commit cd43272
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Harmony/Internal/PatchTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ internal static MethodBase GetOriginalMethod(this HarmonyMethod attr)

case MethodType.Getter:
if (attr.methodName is null)
return AccessTools.DeclaredIndexer(attr.declaringType, attr.argumentTypes).GetGetMethod(true);
return AccessTools.DeclaredProperty(attr.declaringType, attr.methodName).GetGetMethod(true);
return AccessTools.DeclaredIndexerGetter(attr.declaringType, attr.argumentTypes);
return AccessTools.DeclaredPropertyGetter(attr.declaringType, attr.methodName);

case MethodType.Setter:
if (attr.methodName is null)
return AccessTools.DeclaredIndexer(attr.declaringType, attr.argumentTypes).GetSetMethod(true);
return AccessTools.DeclaredProperty(attr.declaringType, attr.methodName).GetSetMethod(true);
return AccessTools.DeclaredIndexerSetter(attr.declaringType, attr.argumentTypes);
return AccessTools.DeclaredPropertySetter(attr.declaringType, attr.methodName);

case MethodType.Constructor:
return AccessTools.DeclaredConstructor(attr.declaringType, attr.argumentTypes);
Expand Down

0 comments on commit cd43272

Please sign in to comment.