From 1b1cf4ec60abdb12281e3ba7edd1c1c7419f7aaa Mon Sep 17 00:00:00 2001 From: de4dot Date: Sun, 8 Jul 2012 08:12:41 +0200 Subject: [PATCH] Add another getMethod() for generics --- blocks/DotNetUtils.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/blocks/DotNetUtils.cs b/blocks/DotNetUtils.cs index 03462a8b..1934060f 100644 --- a/blocks/DotNetUtils.cs +++ b/blocks/DotNetUtils.cs @@ -458,11 +458,23 @@ namespace de4dot.blocks { } public static MethodDefinition getMethod(ModuleDefinition module, MethodReference method) { + if (method == null) + return null; + return getMethod(module, method, method.DeclaringType); + } + + public static MethodDefinition getMethod2(ModuleDefinition module, MethodReference method) { + if (method == null) + return null; + return getMethod(module, method, method.DeclaringType.GetElementType()); + } + + static MethodDefinition getMethod(ModuleDefinition module, MethodReference method, TypeReference declaringType) { if (method == null) return null; if (method is MethodDefinition) return (MethodDefinition)method; - return getMethod(getType(module, method.DeclaringType), method); + return getMethod(getType(module, declaringType), method); } public static MethodDefinition getMethod(TypeDefinition type, string returnType, string parameters) {