Skip to content

Commit 473f11b

Browse files
Merge pull request #4 from manups4e/master
feat(vendor/msgpack): added `GetMethodInfoFromDelegate` to allow getting correct MethodInfo from exception
2 parents d26d04e + 24c759e commit 473f11b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

MsgPack/MsgPackFunc.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ public static MsgPackFunc CreateDelegate(object target, MethodInfo method)
5151
// no need to recreate it
5252
public static MsgPackFunc CreateDelegate(MsgPackFunc deleg) => deleg;
5353

54+
public static MethodInfo GetMethodInfoFromDelegate(MsgPackFunc func)
55+
{
56+
foreach (var kvp in s_wrappedMethods)
57+
{
58+
if (kvp.Value == func.Method)
59+
return kvp.Key;
60+
}
61+
return null;
62+
}
63+
5464
[SecurityCritical]
5565
private static MsgPackFunc ConstructDelegate(object target, MethodInfo method)
5666
{

0 commit comments

Comments
 (0)