{"record":{"id":"e5bbbda3315d77a0","repo":"pardeike/Harmony","slug":"note-info-methodname","errorCode":null,"errorMessage":"{note} [{info.methodName}]","messagePattern":"\\{note\\} \\[\\{info\\.methodName\\}\\]","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Harmony/Public/PatchClassProcessor.cs","lineNumber":148,"sourceCode":"\t\t\t\t\tlock (PatchProcessor.locker)\r\n\t\t\t\t\t\t_ = reversePatcher.Patch();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tList<MethodInfo> BulkPatch(List<MethodBase> originals, ref MethodBase lastOriginal, bool unpatch)\r\n\t\t{\r\n\t\t\tvar jobs = new PatchJobs<MethodInfo>();\r\n\t\t\tfor (var i = 0; i < originals.Count; i++)\r\n\t\t\t{\r\n\t\t\t\tlastOriginal = originals[i];\r\n\t\t\t\tvar job = jobs.GetJob(lastOriginal);\r\n\t\t\t\tforeach (var patchMethod in patchMethods)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar note = \"You cannot combine TargetMethod, TargetMethods or [HarmonyPatchAll] with individual annotations\";\r\n\t\t\t\t\tvar info = patchMethod.info;\r\n\t\t\t\t\tif (info.methodName is not null)\r\n\t\t\t\t\t\tthrow new ArgumentException($\"{note} [{info.methodName}]\");\r\n\t\t\t\t\tif (info.methodType.HasValue && info.methodType.Value != MethodType.Normal)\r\n\t\t\t\t\t\tthrow new ArgumentException($\"{note} [{info.methodType}]\");\r\n\t\t\t\t\tif (info.argumentTypes is not null)\r\n\t\t\t\t\t\tthrow new ArgumentException($\"{note} [{info.argumentTypes.Description()}]\");\r\n\r\n\t\t\t\t\tjob.AddPatch(patchMethod);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tforeach (var job in jobs.GetJobs())\r\n\t\t\t{\r\n\t\t\t\tlastOriginal = job.original;\r\n\t\t\t\tif (unpatch)\r\n\t\t\t\t\tProcessUnpatchJob(job);\r\n\t\t\t\telse\r\n\t\t\t\t\tProcessPatchJob(job);\r\n\t\t\t}\r\n\t\t\treturn jobs.GetReplacements();\r\n\t\t}\r","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/Harmony/Public/PatchClassProcessor.cs#L130-L166","documentation":"When Harmony performs a bulk patch (HarmonyPatchAll / TargetMethods style), target selection is done collectively, so individual patch methods must not also specify a target by name. A patch method carrying methodName alongside TargetMethod/TargetMethods/[HarmonyPatchAll] is ambiguous and is rejected.","triggerScenarios":"BulkPatch processing a patch method whose HarmonyMethod/HarmonyPatch info has a non-null methodName while the class also uses TargetMethod, TargetMethods, or [HarmonyPatchAll].","commonSituations":"Adding [HarmonyPatch(\"SomeMethod\")] to a patch class that already defines a static TargetMethod(); copy-pasting annotated patch methods into an [HarmonyPatchAll] class; refactoring a class from individual annotations to bulk patching without cleaning attributes.","solutions":["Remove the methodName from the patch method's HarmonyPatch/HarmonyMethod attribute and let TargetMethod/TargetMethods decide the target","Or remove TargetMethod/TargetMethods/[HarmonyPatchAll] from the class if you want per-method targeting","Keep target selection in exactly one place per patch class"],"exampleFix":"// before\n[HarmonyPatch(\"Update\")]\nstatic void Postfix() { }\n// class also has: static MethodBase TargetMethod() => ...\n// after\nstatic void Postfix() { } // target comes from TargetMethod()/TargetMethods()","handlingStrategy":"validation","validationCode":"var hasBulk = type.GetMethod(\"TargetMethod\") != null || type.GetMethod(\"TargetMethods\") != null || hasHarmonyPatchAll;\nvar bad = patchMethods.Where(p => p.info.methodName != null);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one targeting style per patch class: either attributes or TargetMethod/TargetMethods","Review patch classes after refactoring between bulk and per-method styles"],"tags":["conflicting-attributes","harmony","annotations","csharp"],"backgroundTag":"conflicting-config-options","analyzedSha":"e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c","analyzedAt":"2026-09-15T22:47:11.550Z","contentChangedAt":"2026-09-15T22:47:11.550Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}