{"record":{"id":"d7a9a93293ea66ed","repo":"pardeike/Harmony","slug":"unsupported-generic-callsite-element-etype","errorCode":null,"errorMessage":"Unsupported generic callsite element: {etype}","messagePattern":"Unsupported generic callsite element: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Harmony/Internal/InlineSignatureParser.cs","lineNumber":188,"sourceCode":"\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tcase MetadataType.RequiredModifier:\r\n\t\t\t\t\t\treturn new InlineSignature.ModifierType()\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tIsOptional = false,\r\n\t\t\t\t\t\t\tModifier = GetTypeDefOrRef(),\r\n\t\t\t\t\t\t\tType = ReadTypeSignature()\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t// System.Reflection lacks SentinelType.\r\n\t\t\t\t\t/*\r\n\t\t\t\t\tcase MetadataType.Sentinel:\r\n\t\t\t\t\t\tthrow new NotSupportedException();\r\n\t\t\t\t\t*/\r\n\r\n\t\t\t\t\tcase MetadataType.Var:\r\n\t\t\t\t\tcase MetadataType.MVar:\r\n\t\t\t\t\t\tthrow new NotSupportedException($\"Unsupported generic callsite element: {etype}\");\r\n\r\n\t\t\t\t\tcase MetadataType.GenericInstance:\r\n\t\t\t\t\t\t_ = reader.ReadByte(); // element type, unused\r\n\t\t\t\t\t\tvar elType = GetTypeDefOrRef();\r\n\t\t\t\t\t\tvar arity = (int)ReadCompressedUInt32();\r\n\r\n\t\t\t\t\t\treturn elType.MakeGenericType(\r\n\t\t\t\t\t\t\t[.. Enumerable.Range(0, arity).Select(_ => (Type)ReadTypeSignature())]\r\n\t\t\t\t\t\t);\r\n\r\n\t\t\t\t\tcase MetadataType.Object:\r\n\t\t\t\t\t\treturn typeof(object);\r\n\r\n\t\t\t\t\tcase MetadataType.Void:\r\n\t\t\t\t\t\treturn typeof(void);\r\n\r\n\t\t\t\t\tcase MetadataType.TypedByReference:\r\n\t\t\t\t\t\treturn typeof(TypedReference);\r","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/Harmony/Internal/InlineSignatureParser.cs#L170-L206","documentation":"InlineSignatureParser.ImportCallSite decodes a binary method-call signature blob into a Cecil CallSite. When the signature contains a generic element type (VAR or MVar — generic type/method parameters) at the callsite level, the parser cannot import it and throws NotSupportedException.","triggerScenarios":"ImportCallSite encountering MetadataType.Var or MetadataType.MVar while decoding a callsite signature — i.e. the target method's signature is a generic parameter (e.g. calling through a generic method's own parameter type in an inline signature).","commonSituations":"Emitting calli instructions against signatures of open generic methods; IL of methods that pass generic type parameters via function pointers; compilers or IL generators emitting open-generic callsite signatures.","solutions":["Close the generic method/type first — build the callsite signature from concrete type arguments, not generic parameters","Avoid emitting inline signatures for open generic methods; emit against a constructed (closed) generic method instead","Restructure the call so it goes through a non-generic delegate or wrapper method","Upgrade Harmony if newer versions add generic callsite support"],"exampleFix":"// before\nsig of open generic: typeof(T) parameter from generic method M<T>\n// after\nvar closed = typeof(Consumer).GetMethod(\"M\").MakeGenericMethod(typeof(int));\n// build callsite from closed method signature","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var callSite = parser.ImportCallSite(module); }\ncatch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported generic callsite element\")) { /* close generics before importing */ }","preventionTips":["Import callsite signatures only from closed (constructed) generic methods","Call MakeGenericMethod with concrete types before emitting signatures","Avoid calli against signatures containing generic type/method variables"],"tags":["signatures","generics","il-parsing","harmony"],"backgroundTag":"unsupported-operation","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"}