From 3e200345a1dc04781286678bfd67384050a9bbe2 Mon Sep 17 00:00:00 2001 From: kumpera Date: Thu, 18 Feb 2010 21:17:18 +0000 Subject: [PATCH] 2010-02-18 Rodrigo Kumpera * reflection.c (mono_reflection_method_on_tb_inst_get_handle): * Handle non generic methods. * reflection.c (mono_reflection_get_custom_attrs_info): Handle * compiler context cases for ParameterInfo. Fixes #579493. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mono@152024 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- mono/metadata/ChangeLog | 10 ++++++++++ mono/metadata/reflection.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 59bf15c05..c0657c6a0 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,3 +1,13 @@ +2010-02-18 Rodrigo Kumpera + + * reflection.c (mono_reflection_method_on_tb_inst_get_handle): Handle non + generic methods. + + * reflection.c (mono_reflection_get_custom_attrs_info): Handle compiler context + cases for ParameterInfo. + + Fixes #579493. + 2010-02-18 Zoltan Varga * class.c (mono_class_get_cctor): Fix support for dynamic classes, which doesn't diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index 515a07c1b..bdbfe7242 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -193,6 +193,8 @@ static gboolean is_sr_mono_generic_method (MonoClass *class); static gboolean is_sr_mono_generic_cmethod (MonoClass *class); static gboolean is_sr_mono_field (MonoClass *class); static gboolean is_sr_mono_property (MonoClass *class); +static gboolean is_sre_method_on_tb_inst (MonoClass *class); +static gboolean is_sre_ctor_on_tb_inst (MonoClass *class); static guint32 mono_image_get_methodspec_token (MonoDynamicImage *assembly, MonoMethod *method); static guint32 mono_image_get_inflated_method_token (MonoDynamicImage *assembly, MonoMethod *m); @@ -2790,6 +2792,9 @@ mono_reflection_method_on_tb_inst_get_handle (MonoReflectionMethodOnTypeBuilderI klass = method->klass; + if (m->method_args == NULL) + return method; + if (method->is_inflated) method = ((MonoMethodInflated *) method)->declaring; @@ -8667,6 +8672,20 @@ mono_reflection_get_custom_attrs_info (MonoObject *obj) g_assert (method); cinfo = mono_custom_attrs_from_param (method, param->PositionImpl + 1); + } else if (is_sre_method_on_tb_inst (member_class)) {/*XXX This is a workaround for Compiler Context*/ + MonoMethod *method = mono_reflection_method_on_tb_inst_get_handle ((MonoReflectionMethodOnTypeBuilderInst*)param->MemberImpl); + cinfo = mono_custom_attrs_from_param (method, param->PositionImpl + 1); + } else if (is_sre_ctor_on_tb_inst (member_class)) { /*XX This is a workaround for Compiler Context*/ + MonoReflectionCtorOnTypeBuilderInst *c = (MonoReflectionCtorOnTypeBuilderInst*)param->MemberImpl; + MonoMethod *method = NULL; + if (is_sre_ctor_builder (mono_object_class (c->cb))) + method = ((MonoReflectionCtorBuilder *)c->cb)->mhandle; + else if (is_sr_mono_cmethod (mono_object_class (c->cb))) + method = ((MonoReflectionMethod *)c->cb)->method; + else + g_error ("mono_reflection_get_custom_attrs_info:: can't handle a CTBI with base_method of type %s", mono_type_get_full_name (member_class)); + + cinfo = mono_custom_attrs_from_param (method, param->PositionImpl + 1); } else { char *type_name = mono_type_get_full_name (member_class); char *msg = g_strdup_printf ("Custom attributes on a ParamInfo with member %s are not supported", type_name); @@ -8889,6 +8908,18 @@ is_sr_mono_property (MonoClass *class) check_corlib_type_cached (class, "System.Reflection", "MonoProperty"); } +static gboolean +is_sre_method_on_tb_inst (MonoClass *class) +{ + check_corlib_type_cached (class, "System.Reflection.Emit", "MethodOnTypeBuilderInst"); +} + +static gboolean +is_sre_ctor_on_tb_inst (MonoClass *class) +{ + check_corlib_type_cached (class, "System.Reflection.Emit", "ConstructorOnTypeBuilderInst"); +} + gboolean mono_class_is_reflection_method_or_constructor (MonoClass *class) { -- 2.11.4.GIT