This project is read-only.

Adding AttributeTargets.Constructor to the ValidOn property of the AttributeUsageAttribute on AttributeUsageAttribute

Topics: General
Aug 28, 2014 at 2:23 PM
I'm using attributes to provide meta-data to generate c# by parsing handwritten c#. However, I'm limited in re-use of terminology via my attribute names. This is because the same attribute is applicable in different places (i.e. it has more than one flag in its AttributeTargets), but not necessarily requiring the same meta-data.

This means I either have to create multiple attributes with convoluted names (e.g. TermOnXTargetAttribute, TermOnYTargetAttribute etc) or have constructor parameters or properties which don't apply to the usage. I want to make it as user friendly and self descriptive as possible, so neither of those is ideal.

I'd expect this to require changes to the compiler and not to the languages or the framework. So that IntelliSence only shows what can be used and incorrect usage produces a CS0592 type error ("Attribute 'attribute' is not valid on this declaration type. It is valid on 'type' declarations only.").