Skip to content

Visual Studio extension that adds commands for copying a Harmony patch implementation to clipboard an IMethod or IProperty symbol.

Notifications You must be signed in to change notification settings

aquafir/HarmonyExtension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HarmonyExtension

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]
      • HarmonyArgumentTypesnew ArgumentType[] { ArgumentType.Normal }
      • HarmonyMethodName nameof(TypeName.MyMethod)
      • HarmonyParamSignature new Type[] { typeof(string) }
      • ManualPatchType prefix
      • MethodDeclarationName PrefixGetMyMethod
      • MethodName MyMethod
      • MethodSignature string foo, ref Bar __instance, ref bool __result
      • PatchTarget Get
      • PatchType Prefix
      • ReturnType bool
      • TypeName 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;

      }

Todo

  • 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
  • Visual Studio Extension

  • Harmony support

About

Visual Studio extension that adds commands for copying a Harmony patch implementation to clipboard an IMethod or IProperty symbol.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages