Reflection.Emit or Pre-compiled Lambda Expression for PropertyDescriptor.SetValue/PropertyDescriptor.GetValue RRS feed

  • Question

  • Hi,

    I have a library where I make these calls:
    PropertyDescriptor.SetValue() and PropertyDescriptor.GetValue()

    because I don't know the properties before run-time, and the properties are added on demand, using TypeDescriptor.
    The problem is that these calls are really slow. How do I emit these call with Reflection Emit (using IL directly), or use  Pre-compiled Lambda Expression to cache method delegate for these calls ?

    Thanks in advance.

    Saturday, January 4, 2014 2:32 AM

All replies

  • This depends on how those properties are added but in general there's no way to do what you want with property descriptors.

    Keep in mind that property descriptors were mainly intended for "design time" use, for example the property grid control uses them. If you're using property descriptors for anything else and you find that the performance is lacking, well, you're probably using the wrong tool for the job.

    Saturday, January 4, 2014 7:53 AM