I am writing a custom attribute. I have applied the AttributeUsage
attribute to it, restricting its use to properties only. This works fine: trying to use the attribute on a class or method results in a design-time error, which is exactly what I want.
I would like to restrict it further, so it can be used only on properties that return a String
. That is to say, it will result in a design-time error if applied to a DateTime
or other non-string. Is this kind of precision possible and, if so, how would I do it?