public static Method ReverseEngineer(System.Reflection.MethodInfo _method) { Method method = new Method(); //decompile method body if (!_method.IsAbstract && !_method.IsCompilerGenerated()) { Mono.Cecil.AssemblyDefinition ass = Decompiler.LoadAssembly(_method.DeclaringType.Module.Assembly.Location); MethodDefinition md = ass.MainModule.GetType(_method.DeclaringType.FullName).Methods.Where(md2 => md2.Name == _method.Name).Select(md2 => md2).First(); method.MethodCode = Decompiler.GetSourceCode(md); } method.Name = _method.Name; method.Type = ReverseEngineer(_method.DeclaringType); method.ReturnType = ReverseEngineer(_method.ReturnType); method.IsStatic = _method.IsStatic; method.IsAbstract = _method.IsAbstract; method.IsVirtual = _method.IsVirtual; method.Access = _method.GetAccessModifier(); DataBase.Current.Set <Method>().Add(method); foreach (System.Reflection.ParameterInfo _param in _method.GetParameters()) { MethodArgument ma = new MethodArgument(); ma.Method = method; ma.Name = _param.Name; ma.Type = ReverseEngineer(_param.ParameterType); DataBase.Current.Set <MethodArgument>().Add(ma); } if (_method.IsGenericMethod || _method.IsGenericMethodDefinition || _method.ContainsGenericParameters) { foreach (System.Type _genericArg in _method.GetGenericArguments()) { MethodGenericArgument genericArg = new MethodGenericArgument(); genericArg.ArgumentType = ReverseEngineer(_genericArg); genericArg.Position = _genericArg.GenericParameterPosition; genericArg.AppliedTo = method; DataBase.Current.Set <MethodGenericArgument>().Add(genericArg); } } return(method); }