Skip to content

Commit

Permalink
Merge pull request #565 from Zetrith/master
Browse files Browse the repository at this point in the history
Support GenericInstance types in inline method signatures
  • Loading branch information
pardeike authored Feb 2, 2024
2 parents 7b4e5ef + 1960f57 commit 03b6426
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 03b6426

Please sign in to comment.