Just noting this is valid, verifiable IL (i.e.
.class public sequential ansi sealed StructNewStruct`1<valuetype .ctor ([mscorlib]System.ValueType) T>
extends [mscorlib]System.ValueType
compiles, as does the simpler
.class public sequential ansi sealed StructNewStruct`1<valuetype .ctor T>
extends [mscorlib]System.ValueType
) but I don't yet have code that does anything different for these that a simple where T:struct
(or (Of T As Structure)
in VB.NET and <valuetype T>
in IL) provides.
Specifically, Nullable
structs are already not allowed for any generic argument with a simple struct
constraint. (It does seem Nullable
objects are classes for almost all purposes except storage.)
So, in summary, Nullable<T>
's current (equivalent of) where T:ValueType, struct, new()
seems to currently be identical to where T:struct
.
For your information I used my updated DotLisp that allows the creation of generic types (just using MakeGenericType
) to attempt to create a type of StructNewStruct<t>
and StructStruct<t>
(*) for all types in all assemblies of the 4.0 Framework that load without me trying to load "unusual" assemblies (e.g. System.Web
may not have been loaded). (If there are any "special" types in "obscure" framework assemblies let me know and I'll ensure they're loaded and tried.) All types succeeded or failed the same with both structures.
(*) StructStruct<T> where T:struct