MC++ FAQ
Sunday 02 | 01 | 2004
Attributes and Properties
If you need to apply a custom attribute to a property in MC++, applying it to either the get_XXX or set_XXX method should be enough. Putting it on either one should work. Actually, if you put it in both, the resulting property metadata might end up associated with the same attribute twice (easy to verify by using ILDASM).

By default, an attribute applied to a __property method will be applied to the property as a whole [1]. To get the attribute to apply to the method, you have to precede it with "method:" like this:


 [ method: ComVisible(true) ]
 __property int get_Val() { return 4; }

[1] I presume the compiler could possibly apply it by default to the method if it's an attribute that does not apply to properties, but I doubt the compiler actually checks this... haven't tried it, though...

Posted by tomasr at February 01, 2004 03:25 PM
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63