This is a common problem with code-generation; while you can add members and class level attributes via an additional partial class, you can't add attributes to the generated members. To compensate, some attribute-based mechanisms allow you to specify the attributes at the class (naming the member), but not any of the ones you cite.
One hardcore option would be to write a TypeDescriptionProvider
that supplies custom PropertyDescriptor
definitions for the properties. This would allow you to fully control the metadata used by UI binding tools like PropertyGrid
, DataGridView
, etc.
However, this is possibly too much work simply to set a few UI propertiex if you can also set them by hand! But if you are interested in pursuing that option, let me know - it is a familiar area to me, but too much code to write an example if you don't want it.
Note: if you are using PropertyGrid
, then you can't set the properties by hand, but you can write a TypeConverter
, which is a bit less work than a full TypeDescriptionProvider
; just inherit from ExpandableObjectConverter
and override GetProperties()
. You'll still need a shim PropertyDescriptor
, so still not trivial...