Problem
For some attributes (e.g. TypeConverterAttribute) that are used to reference types, the current usage looks like this:
[TypeConverter(typeof(X))]
This has two disadvantages:
- You can't guarantee that the type matches the requirements of the attribute -- e.g. has an empty constructor or inherits
TypeConverter.
- The syntax is a bit verbose.
Suggestion
I suggest that the generic attributes should be supported, including any generic constraints.
Usage example:
Pros
- Support for type constraints in type-referencing attributes
- Shorter syntax
- As far as I know, generic attributes are already supported in IL
Cons
The set of attributes that benefit from this might not be that large.
Updates
Removed pro 4 as it wasn't a pro.
Problem
For some attributes (e.g.
TypeConverterAttribute) that are used to reference types, the current usage looks like this:This has two disadvantages:
TypeConverter.Suggestion
I suggest that the generic attributes should be supported, including any generic constraints.
Usage example:
Pros
Cons
The set of attributes that benefit from this might not be that large.
Updates
Removed pro 4 as it wasn't a pro.