pardeike/Harmony · error · ArgumentException

[ ]

Error message

{note} [{info.methodType}]

What it means

Same family as the methodName conflict: in bulk-patch mode the target is chosen by TargetMethod/TargetMethods/[HarmonyPatchAll], so a patch method must not pin a specific MethodType (e.g. Getter, Setter, Constructor). Harmony throws to avoid the ambiguity of two independent target selectors.

Solutions

  1. Remove the MethodType from the patch method and return the property getter/setter or constructor directly from TargetMethod()/TargetMethods()
  2. Or move the patch to its own class without bulk-targeting attributes and keep the MethodType there

Example fix

// before (in [HarmonyPatchAll] class)
[HarmonyPatch(MethodType = MethodType.Getter)]
static void Postfix() { }
// after
static IEnumerable<MethodBase> TargetMethods()
{
    yield return AccessTools.Property(typeof(Foo), "Bar").GetGetMethod();
}
Defensive patterns

Strategy: validation

Validate before calling

if (hasBulkTargeting && patchMethods.Any(p => p.info.methodType is not null and not MethodType.Normal)) throw ...;

Prevention

When it happens

Trigger: BulkPatch encounters a patch method whose info.methodType is set to anything other than MethodType.Normal while the class uses TargetMethod/TargetMethods/[HarmonyPatchAll].

Common situations: [HarmonyPatch(MethodType = MethodType.Getter)] inside an [HarmonyPatchAll] class; migrating property/constructor patches into a bulk-patched class.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of pardeike/Harmony@e7872dc170 (2026-09-15). Data as JSON: /api/errors/3fec162cb652667c. Report an issue: GitHub.

Appendix: source

Thrown at Harmony/Public/PatchClassProcessor.cs:150

				}
			}
		}

		List<MethodInfo> BulkPatch(List<MethodBase> originals, ref MethodBase lastOriginal, bool unpatch)
		{
			var jobs = new PatchJobs<MethodInfo>();
			for (var i = 0; i < originals.Count; i++)
			{
				lastOriginal = originals[i];
				var job = jobs.GetJob(lastOriginal);
				foreach (var patchMethod in patchMethods)
				{
					var note = "You cannot combine TargetMethod, TargetMethods or [HarmonyPatchAll] with individual annotations";
					var info = patchMethod.info;
					if (info.methodName is not null)
						throw new ArgumentException($"{note} [{info.methodName}]");
					if (info.methodType.HasValue && info.methodType.Value != MethodType.Normal)
						throw new ArgumentException($"{note} [{info.methodType}]");
					if (info.argumentTypes is not null)
						throw new ArgumentException($"{note} [{info.argumentTypes.Description()}]");

					job.AddPatch(patchMethod);
				}
			}
			foreach (var job in jobs.GetJobs())
			{
				lastOriginal = job.original;
				if (unpatch)
					ProcessUnpatchJob(job);
				else
					ProcessPatchJob(job);
			}
			return jobs.GetReplacements();
		}

		List<MethodInfo> PatchWithAttributes(ref MethodBase lastOriginal, bool unpatch)

View on GitHub (pinned to e7872dc170)