FlatSharp v4.1.0 Release Notes

Release Date: 2020-10-17 // about 1 year ago
  • ๐Ÿ”– Version 4.1.0 is a minor release and builds on the performance improvements in 4.0.0.

    ๐Ÿ”ง The main improvement in version 4.1.0 is support for new configurations for properties:

    • ๐Ÿ‘ Non-virtual properties now supported (setters are required). Non-Virtual properties are always deserialized greedily.
    • ๐Ÿ‘ Protected and Protected Internal setters now supported

      [FlatBufferTable]public class MyTable{ [FlatBufferItem(0)] public virtual int VirtualInt { get; protected set; } [FlatBufferItem(1)] public string NonVirtualString { get; protected internal set; } [FlatBufferItem(2)] public virtual int ReadOnlyInt { get; } }

    ๐Ÿ‘ FBS files also support these:

    table MyTable // nonVirtual is supported at the table level to set a default for all properties.
    {
       VirtualInt:int (setter:"protected");
       NonVirtualString:string (setter:"protectedinternal", nonVirtual);
       ReadOnlyVirtualInt:int (setter:"none");
    }
    

    โž• Additionally, the FlatSharp compiler now supports the ObsoleteDefaultConstructor attribute on tables and structs to apply a [Obsolete] attribute to the generated default constructor. This can help create immutable objects.


Previous changes from v4.0.0

  • ๐Ÿ”– Version 4 is a significant milestone for FlatSharp, and represents the culmination of a lot of work. Hope you enjoy it, to the extent that it's possible to enjoy a serialization library!

    What's new?

    Glad you asked!

    • ๐Ÿ‘Œ Support for optional/nullable scalars (tables only) (google/flatbuffers#6014)
    • ๐Ÿ‘Œ Support for "indexed vectors", which are Vectors that look and act like Dictionaries. Under the hood, these are sorted vectors that expose a simpler programming model, so it's no longer necessary to worry about whether a vector is sorted or not. Check out the indexed vectors sample!
    • ๐Ÿ‘ Shared strings are now supported in sorted vectors
    • ๐Ÿ†• New method of publishing benchmark data, benchmarks extended to include .NET 5.0

    Internal stuff

    ๐ŸŽ Lots of work went into optimizing how the CLR JIT treats FlatSharp's code. Performance is increased anywhere from 10 - 30% relative to version 3.3.1.

    • Much of this improvement was changes to allow the JIT to elide virtual function calls when invoking methods on SpanReader and InputBuffer. More background is available here: dotnet/runtime#32815

    - Other changes involved removing some unnecessary branches and function calls on hot paths

    ๐Ÿ”Œ FlatSharp's backend was completely rewritten to be more modular, so that future types can be supported more easily. It is now possible (though not advised) to write your own plugins. This amounted to a rewrite of a large part of the code.

    ๐Ÿ’ฅ Breaking Changes

    FlatSharp adheres to semantic versioning, and there are breaking public API changes in version 4:

    • SpanWriter has been changed from a class to a struct. It is no longer inheritable. A new ISpanWriter interface has been introduced should you wish to provide your own.
    • UnsafeSpanWriter remains a class, but is sealed.
    • ๐Ÿšš The base class InputBuffer has been removed. It has been replaced with IInputBuffer
      • ArrayInputBuffer, MemoryInputBuffer, ReadOnlyMemoryInputBuffer, and the unsafe variants remain the same.
    • ๐Ÿ‘Œ Support for memory vectors has been dropped for all types but byte. This was to address a design oversight where precompiled serializers would produce incorrect results when running on big-endian platforms.
      • Memory<byte> and ReadOnlyMemory<byte> remain supported.