pardeike/Harmony · error · NotSupportedException

Unsupported inline signature parameter type

Error message

Unsupported inline signature parameter type: {param} ({param?.GetType().FullDescription()})

What it means

InlineSignature builds call-site / function-pointer signatures for IL emission. GetTypeReference converts each parameter object (Type, InlineSignature, or ModifierType) into a Cecil TypeReference; any other object shape is unsupported and throws NotSupportedException naming the offending object and its runtime type.

Solutions

  1. Pass a System.Type for normal parameter types instead of a string or custom object
  2. Use InlineSignature for nested function-pointer parameters and ModifierType for modreq/modopt parameters
  3. Check for null entries in the parameter list — the message prints the type only for non-null values
  4. Upgrade Harmony if you believe a valid element kind is being rejected

Example fix

// before
new InlineSignature(typeof(void), "int", typeof(IntPtr));
// after
new InlineSignature(typeof(void), typeof(int), typeof(IntPtr));
Defensive patterns

Strategy: type-guard

Validate before calling

bool IsSupportedParam(object p) => p is Type or InlineSignature or ModifierType;

Type guard

static bool IsSupportedSignatureParam(object? param) => param is Type or InlineSignature or ModifierType;

Try / catch

try { var fptr = sig.ToFunctionPointer(module); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Unsupported inline signature parameter type")) { /* inspect offending param type and fix construction */ }

Prevention

When it happens

Trigger: Constructing an InlineSignature (ToCallSite/ToFunctionPointer/callsite/fptr paths) with a parameter item that is not a System.Type, not an InlineSignature, and not a ModifierType — e.g. passing a raw string type name, null placeholder, or a custom signature element type.

Common situations: Hand-writing calli/function-pointer signatures for native or generic function pointers and using the wrong representation for a parameter; library-version drift where an element type was previously accepted.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at Harmony/Internal/InlineSignature.cs:48

		public List<object> Parameters { get; set; } = [];

		/// <summary>The return type or function pointer signature returned by the call site</summary>
		///
		public object ReturnType { get; set; } = typeof(void);

		/// <summary>Returns a string representation of the inline signature</summary>
		/// <returns>A string representation of the inline signature</returns>
		///
		public override string ToString() => $"{(ReturnType is Type rt ? rt.FullDescription() : ReturnType?.ToString())} ({Parameters.Join(p => p is Type pt ? pt.FullDescription() : p?.ToString())})";

		internal static TypeReference GetTypeReference(ModuleDefinition module, object param)
		{
			return param switch
			{
				Type paramType => module.ImportReference(paramType),
				InlineSignature paramSig => paramSig.ToFunctionPointer(module),
				ModifierType paramMod => paramMod.ToTypeReference(module),
				_ => throw new NotSupportedException($"Unsupported inline signature parameter type: {param} ({param?.GetType().FullDescription()})"),
			};
		}

		CallSite ICallSiteGenerator.ToCallSite(ModuleDefinition module)
		{
			var callsite = new CallSite(GetTypeReference(module, ReturnType))
			{
				HasThis = HasThis,
				ExplicitThis = ExplicitThis,
				CallingConvention = (MethodCallingConvention)CallingConvention - 1
			};

			foreach (var param in Parameters)
				callsite.Parameters.Add(new ParameterDefinition(GetTypeReference(module, param)));

			return callsite;
		}

View on GitHub (pinned to e7872dc170)