[Mono-dev] MonoProperty and generic types

Bartosz Przygoda bprzygoda at gmail.com
Tue Jul 23 11:27:09 UTC 2013


I'm obtaining the *Capacity *property from the *List<T>* class:

    class_ = mono_class_from_name(image, "System.Collections.Generic",
    _Capacity = mono_class_get_property_from_name(list, "Capacity");

Then, I'm able to call the getter on given instance:

    mres = mono_property_get_value(_Capacity, list, nullptr, &exc);

it returns correct value, however:

    void* params[1] = { (void*)&capacity };
  mono_property_set_value(_Capacity, list, params, &exc);

aborts the runtime (during method jitting).

If I fetch the property in following way (from the class of given instance
isntead of from List`1 class:

    cl = mono_object_get_class(list);
  prop = mono_class_get_property_from_name (cl, "Capacity");

then it works correctly.

Is it invalid to try to do this in a way I've described?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130723/28fa0f07/attachment.html>

More information about the Mono-devel-list mailing list