As is well known, in C# one can specify the target of a custom attribute specification, as in the example
[method: SomeDecoration]
[return: SomeOtherMark]
int MyMethod();
where the "targets" method: and return: help specify what element in the code the attribute belongs to.
According to the C# Language Specification, the following attribute targets exist:
- Global ones:
assemblymodule
- Others:
fieldeventmethodparampropertyreturntype
Some of them, like field, are always redundant, since it is always clear what the attribute "sits" on without specifying them.
However there does exist (at least in the implementation and version of Visual C# I have here) an additional attribute target, namely:
typevar
which is allowed for example in the code
class MyGenericCollection<[typevar: HereYouSee] TItem> // legal
{
}
The attribute target typevar, just like field and others, is never required.
My question: Does anyone know the historic reason why typevar: is not mentioned in the specification or documentation? Was this simply forgotten when the 2.0 version of the C# Language Specification was written? Or if it was not an oversight, why is it implemented at all?