Skip to content

Generating multiple serializers for the same types #352

Answered by jamescourtney
Astn asked this question in Q&A
Discussion options

You must be logged in to vote

FlatSharp v7 does this by default: https://github.com/jamescourtney/FlatSharp/releases/tag/7.0.0. The fs_serializer attribute now only specifies the default serializer for YourType.Serializer. There are a few ways to gain access to the other serializers:

  • YourType.Serializer.Parse(buffer, FlatBufferDeserializationOption.Progressive)
  • var progressiveSerializer = YourType.Serializer.WithSettings(opts => opts.UseProgressiveDeserialization());
  • If on .NET 7:
public static T ParseProgressive<T>(byte[] buffer) where T : IFlatBufferSerializable<T>
{
    return T.ProgressiveSerializer.Parse(buffer);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jamescourtney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants