Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut for patching all method overloads? #62

Open
myocytebd opened this issue Jan 21, 2023 · 1 comment
Open

Shortcut for patching all method overloads? #62

myocytebd opened this issue Jan 21, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@myocytebd
Copy link

Is your feature request related to a problem? Please describe.
Patching all method overloads is relatively verbose now, requiring manual patching which adds about 10 lines of code per patch.
(TargetMethods() requires extra classes; while Harmony.Patch() requires extra bookkeeping. So it becomes about 10 lines of code.)

Describe the solution you'd like
If it is available in Attribute, it would be 0 line of code per patch and cleaner.
IMHO Attribute way is cleaner because:

  • TargetMethods()'s requirement of extra classes make it verbose (and does not cope with HarmonyPatch.CreateAndPatchAll);
  • Harmony.Patch() separates hook target from hook implementation.

Describe alternatives you've considered
Either [HarmonyPatch(Type, string, [new-enum-overload-all])],
or [HarmonyPatch(Type{target-class}, [new-enum]{custom-filter-indicator}, Type{custom-filter}, ... {args forward to custom filter}])],
or [HarmonyPatch(Type{target-class}, [new-enum]{custom-filter-indicator}), TargetMethods(Type{custom-filter}, ... {args forward to custom filter}])].

@ManlyMarco ManlyMarco added the enhancement New feature or request label Jan 22, 2023
@ManlyMarco
Copy link
Member

Good idea. It could be added to the method type enum since this is only ever applicable to methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants