{"record":{"id":"756a1c9bddaf4506","repo":"pardeike/Harmony","slug":"note-info-argumenttypes-description","errorCode":null,"errorMessage":"{note} [{info.argumentTypes.Description()}]","messagePattern":"\\{note\\} \\[\\{info\\.argumentTypes\\.Description\\(\\)\\}\\]","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Harmony/Public/PatchClassProcessor.cs","lineNumber":152,"sourceCode":"\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\n\r\n\t\tList<MethodInfo> PatchWithAttributes(ref MethodBase lastOriginal, bool unpatch)\r\n\t\t{\r\n\t\t\tvar jobs = new PatchJobs<MethodInfo>();\r","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/Harmony/Public/PatchClassProcessor.cs#L134-L170","documentation":"In bulk-patch mode, a patch method must not specify argumentTypes to disambiguate overloads, because the target is already fully determined by TargetMethod/TargetMethods/[HarmonyPatchAll]. Harmony rejects the combination to prevent conflicting target selection.","triggerScenarios":"BulkPatch processing a patch method whose HarmonyMethod info.argumentTypes is non-null while TargetMethod/TargetMethods/[HarmonyPatchAll] is in use on the class.","commonSituations":"Copy-pasting individually annotated overloads into an [HarmonyPatchAll] class; adding [HarmonyPatch(typeof(Foo), \"Bar\", typeof(int))] attributes next to a TargetMethods() implementation.","solutions":["Remove argumentTypes from the patch method's attribute and rely on TargetMethods() to yield the exact overload","Move that overload-specific patch into its own patch class without bulk-targeting attributes"],"exampleFix":"// before\n[HarmonyPatch(typeof(Foo), \"Bar\", new[] { typeof(int) })]\nstatic void Postfix() { }\n// after\nstatic IEnumerable<MethodBase> TargetMethods()\n{\n    yield return AccessTools.Method(typeof(Foo), \"Bar\", new[] { typeof(int) });\n}","handlingStrategy":"validation","validationCode":"if (hasBulkTargeting && patchMethods.Any(p => p.info.argumentTypes != null)) throw ...;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve overloads inside TargetMethods() via AccessTools.Method(type, name, types) rather than argumentTypes attributes in bulk classes"],"tags":["conflicting-attributes","overloads","harmony","annotations"],"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"}