Table of Contents
Further methods along the lines of Harmony's HarmonyLib.AccessTools
public static class MoreAccessTools
Inheritance System.Object MoreAccessTools
Safely gets the MethodInfo for a method within a nested class. This is recommended to use because over
directly targeting it with typeof and nameof because the nested class names can change randomly.
public static System.Reflection.MethodInfo SafeGetNestedClassMethod(System.Type outerType, string nestedTypeName, string methodName="MoveNext", int index=0);
outerType
System.Type
The outer type whose name won't change
nestedTypeName
System.String
The name of nested type, not including the _s
methodName
System.String
The desired method name within the nested type
index
System.Int32
If multiple nested classes share a name portion, use the one at this index, default 0
System.Reflection.MethodInfo
The MethodInfo, or null alongside a console warning if one couldn't be found
Safely gets the MethodInfo for a method within a nested class. This is recommended to use because over
directly targeting it with typeof and nameof because the nested class names can change randomly.
public static bool TryGetNestedClassMethod(System.Type outerType, string nestedClassName, string methodName, out System.Reflection.MethodInfo method, int index=0);
outerType
System.Type
The outer type whose name won't change
nestedClassName
System.String
methodName
System.String
The desired method name within the nested type
method
System.Reflection.MethodInfo
index
System.Int32
If multiple nested classes share a name portion, use the one at this index, default 0
System.Boolean
The MethodInfo, or null alongside a console warning if one couldn't be found