[sre] register a canonical MonoReflectionMethod for a methodref token
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 27 Sep 2017 18:01:47 +0000 (14:01 -0400)
committerMarek Safar <marek.safar@gmail.com>
Fri, 29 Sep 2017 09:01:31 +0000 (11:01 +0200)
commit391dca598831ef87d928354824d5861909cbfb6d
tree2cecdcf8e9d9f4e7185ca464e8a88588b61220b2
parentb45143416802d23bbd8963bf2e15117385d95b76
[sre] register a canonical MonoReflectionMethod for a methodref token

In mono_image_create_token we are passed in a managed reflection object and we
need to create a token for it and optionally register it so that we can resolve
that token back to a runtime structure and managed object later.

For a MonoReflectionMethod object that refers to a method from outside the
current dynamic image, we need to generate a memberref token.  It will be the
same token for the same underlying MonoMethod*.  When we go to register the
token with mono_dynamic_image_register_token we need to pass a managed object.
Unfortunately two MonoReflectionMethod objects could refer to the same
MonoMethod* but differ in their ReflectedType, so just registering the
passed-in MonoReflectionMethod means we could assert in
mono_dynamic_image_register_token because previously we may have registered the
same method via a different ReflectedType.

So what we do is we cal mono_method_get_object_handle with NULL for the
reflected type - which corresponds to just using the DeclaringType of the given
MonoMethod*.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=59364
mono/metadata/sre.c