Harmony
Harmony copied to clipboard
Allows empty string for targeting special MethodType options and doesn't try searching for it with AccessTools
trafficstars
Allows patch attributes like [HarmonyPatch(typeof(TargetType), "", MethodType.Getter)] on a method, or
[HarmonyPatch(typeof(TargetType))]
static class PatchClass
{
[HarmonyPatch("", MethodType.Getter)]
static void Postfix() { }
}
to target an Indexer for example. With just null instead of "", the second example would be ambiguous.
This may allow making the targeting "nameless" members like (static) constructors or indexers more explicit, by allowing to provide an empty string in addition to the MethodType or null. Now that I'm writing this, it seems almost unnecessary, but the idea came while talking about possible Analyzers for HarmonyPatch attributes
For the AccessTools methods, it checks for empty string as well, as there can't be members with that name. Not with whitespace either, but net3.5 doesn't have that method.