Proposal: Generics in Attributes #4782
-
In C#, attributes are often used to declare a relationship to a type. Today, we cannot use generics for this; thus, we end up with attributes like the following example and rely on runtime checking that the type is valid.
Instead, it would be awesome if we could have something like this, and compile-time enforce constraints on the generic type.
Furthermore, it would be very useful if we could use the type on which the attribute is declared in the attribute type definition. I.e.
where TDeclarer would be Test Similar for properties:
where TDeclarer would be string. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Duplicate of #124. |
Beta Was this translation helpful? Give feedback.
Duplicate of #124.