type My(id: Nullable<int>) = member x.Id = id
let pickler = FsPickler()
let ms = new MemoryStream()
pickler.Serialize (ms, My(Nullable 3))
which results the following error:
System.ArgumentException: GenericArguments[0], 'System.Nullable`1[System.Int32]', on 'FsPickler.Pickler`1[T] Create[T](FsPickler.IPicklerResolver)' violates the constraint of type 'T'. ---> System.Security.VerificationException: Method FsPickler.DotNetPicklers+StructPickler.Create: type argument 'System.Nullable`1[System.Int32]' violates the constraint of type parameter 'T'.
at System.RuntimeMethodHandle.GetStubIfNeeded(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[] methodInstantiation)
at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
--- End of inner exception stack trace ---
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
at FsPickler.DotNetPicklers.StructPickler.CreateUntyped(Type t, IPicklerResolver resolver)
at FsPickler.PicklerResolution.lookup@31.Invoke(Type t)
at FsPickler.DotNetPicklers.ClassPickler.Create[T](IPicklerResolver resolver)
at FsPickler.Utils.MethodInfo.GuardedInvoke(MethodInfo m, Object instance, Object[] parameters)
at FsPickler.DotNetPicklers.ClassPickler.CreateUntyped(Type t, IPicklerResolver resolver)
at FsPickler.PicklerResolution.lookup@31.Invoke(Type t)
at FsPickler.PicklerCache.FsPickler-IPicklerResolver-Resolve[T]()
at FsPickler.FsPickler.Serialize[T](Stream stream, T value, FSharpOption`1 streamingContext, FSharpOption`1 encoding, FSharpOption`1 leaveOpen)
at <StartupCode$FSI_0011>.$FSI_0011.main@()
which results the following error: