Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.
This repository was archived by the owner on Jun 10, 2026. It is now read-only.

Allow serializers for a generic type #4

Description

I need serialization of generic types.

Let I have a generic type:

type T<'a>(a: 'a) =
   member x.A = a

I want to serialize instances of this type T(10), T("abc") and would create a serializer type as follows:

let TSerializer<'a>() =
  interface ISerializer<'a> with
    member x.TypeId = "T"
    member x.Serialize _ t -> ...
    member x.Deserializer _ is -> ...

Now only non-generic serializers can be registered in a serializer library. But still it seems possible to do the following, if a serializer type has same order and number of type parameters as its target type:

lib.Register(typedefof<TSerializer<_>>)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions