Skip to content

Commit

Permalink
Support GenericInstance types in inline method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetrith committed Jan 14, 2024
1 parent 1b16c96 commit 1960f57
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Harmony/Internal/InlineSignatureParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Mono.Cecil;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -185,9 +186,17 @@ object ReadTypeSignature()

case MetadataType.Var:
case MetadataType.MVar:
case MetadataType.GenericInstance:
throw new NotSupportedException($"Unsupported generic callsite element: {etype}");

case MetadataType.GenericInstance:
reader.ReadByte(); // element type, unused
var elType = GetTypeDefOrRef();
var arity = (int)ReadCompressedUInt32();

return elType.MakeGenericType(
Enumerable.Range(0, arity).Select(_ => (Type)ReadTypeSignature()).ToArray()
);

case MetadataType.Object:
return typeof(object);

Expand Down

0 comments on commit 1960f57

Please sign in to comment.