This is a Visual Studio extension that adds commands for copying a selected symbol as a Harmony patch, customized by the options.
-
Templating
-
Insert a variable by using a
$
follow by its case-insensitive name:$varToInsert
-
Variables/examples available:
Annotations
[HarmonyPatch(typeof(TypeName), nameof(TypeName.MyMethod), MethodType.Getter), new Type[] { typeof(string) }]AnnotatedPatchType
[HarmonyPrefix]HarmonyArgumentTypes
new ArgumentType[] { ArgumentType.Normal }HarmonyMethodName
nameof(TypeName.MyMethod)HarmonyParamSignature
new Type[] { typeof(string) }ManualPatchType
prefixMethodDeclarationName
PrefixGetMyMethodMethodName
MyMethodMethodSignature
string foo, ref Bar __instance, ref bool __resultPatchTarget
GetPatchType
PrefixReturnType
boolTypeName
TypeName
-
Default Manual Template
var originalMethod = AccessTools.Method(typeof($typeName), $methodName);
var patchMethod = AccessTools.Method(typeof(PatchClass), nameof(PatchClass.$methodDeclarationName), $harmonyParamSignature);
var patch = new HarmonyMethod(patchMethod);
harmony.Patch(original, $manualPatchType: patch);
public static $returnType $methodDeclarationName($methodSignature) {
//Return false to override
//return false;
//Return true to execute original
//return true;
}
-
Default Annotated Template
$annotatedPatchType
$annotations
public static $returnType $methodDeclarationName($methodSignature) {
//Return false to override
//return false;
//Return true to execute original
//return true;
}
-
-
Templating
- Add support for context-aware insertions (e.g., template variables for destination Type)
- Better template settings design
- Conditionals / templates for each combination of:
- Return type
- Type
- Target
- Style
-
Options menu- Submenu
- Context
-
Harmony support
Manual patching- Cascading patches, if applicable
- Add default values?
- Annotations
- Priority
- Patch types
- Type
- Patch everything in a type
- Inject fields from a type