Some special CLI types from mscorlib library (ArgIterator
, TypedReference
and RuntimeArgumentHandle
types) cannot be used as generic type parameters to construct the generic types / methods:
void Foo<T>() { }
void Bar() { Foo<ArgIterator>(); }
provides the compiler error:
error CS0306: The type 'System.ArgIterator' may not be used as a type argument
But this is not documented at all in the C# specification.
Is this types are a part of CLI specification or this types provided by CLR implementation and the behavior described above should not be documented at C# spec?
First off, Jon is again correct -- these guys are very special types whose values are not convertible to object, and so cannot be used as type arguments. All type arguments must be types whose values are convertible to object.
To answer your question about documentation:
None of the special features for handling variadic methods are documented. They are not a part of the C# language itself -- a conforming implementation of the language is not required to be able to do interop with languages that support variadic methods. Nor are these features documented in MSDN as part of the compiler documentation. These are not "officially supported" features.
This is unfortunate, but there's only so much budget available, and I think most people would agree that we'd do better to write features and fix bugs than to spend money documenting features that literally 99.99% of our users will never, ever use even if they were supported, which they're not.
If you want to go do interop in C# with variadic methods, you're on your own. Good luck!