Skip to content

Version 4.1.0: Non-Virtual Properties and FBS Annotations

Compare
Choose a tag to compare
@jamescourtney jamescourtney released this 17 Oct 21:39
f6115ca

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.