A small set of analyzers (and an even smaller set of code fixes) to assist writing Harmony patches, primarily to identify common errors such as missing attributes, typos in names, etc. Also provides autocomplete suggestions for patch method argument injections.
Completion suggestions are provided for patch method parameter injections and for the argumentTypes
argument to the [HarmonyPatch]
attribute.
Methods with [HarmonyPatch]
attributes in class without a [HarmonyPatch]
attribute.
A method with a [HarmonyPatch]
patch type method attribute that is not named Postfix
, Prefix
, Transpiler
, etc.
MethodType
argumentA [HarmonyPatch]
attribute without a methodType
parameter and targeting a method that is not a standard method (eg. property accessor, constructor, indexer).
A patch targeting an overloaded method and without an argumentTypes
argument.
No method matching the provided {HarmonyPatch}
arguments was found.
A class with a [HarmonyPatch]
attribute and no patch methods.
A patch class containing [HarmonyPatch]
arguments and TargetMethod
or TargetMethods
methods.
Assignment to a non-ref
, non-out
patch method argument.
Patch method return type is not value for its patch type (IEnumerable<CodeInstruction>
for a transpiler, void
or bool
for a prefix, etc.)
[HarmonyPatch]
attribute conflictMultiple [HarmonyPatch]
attributes applied to a method (and/or class) with conflicting target method arguments.
eg. HarmonyPostfix
and HarmonyPrefix
.
__result
injection in passthrough PostfixAn injected __result
argument in a passthrough postfix method's parameters.
An injected argument does not match any parameter on the target method.
The type of an injected argument does not match the type of the argument on the target method with the same name.
Invalid injected arguments in a transpiler method.
out
for __state
in prefix patchesAn __state
parameter injection in a prefix patch should be out
.
Argument injections should use the parameter names from the target method and not index (__0
, __1
, etc.)
Non-transpiler reverse patch signature must match the target method.
Fixes are provided for the following rules:
Analysis is currently not fully implemented for reverse patches and not at all for ReturnRef<T>
.