FlatSharp 7 Breaking Changes
jamescourtney opened this issue · comments
This is a set of tracking issues to consider for FlatSharp 7, whenever that becomes a thing. For anyone reading, this does not indicate that FlatSharp 7 is imminent, or even being actively worked on. This is simply a list of breaking changes that are being earmarked for that release.
Small Items
- Make
snake_case
toPascalCase
transformation opt-out instead of opt-in: #275 - Merge
IInputBuffer2
intoIInputBuffer
, deleteIInputBuffer2
Add support for source generators. Possibly unityFlatSharp
andFlatSharp.Compiler
into a single generator package. That can deal with FBS and attribute based schemas.
Rework FBS Codegen
Rework FBS codegen to reduce code duplication. Today FlatSharp generates an entire recursive parse/serialize chunk of code for each unique root type. This is a problem in the following case:
flowchart LR
RootA & RootB --> GiantObjectC
RootA --> D
GiantObjectC --> E & F
Large FlatBuffer tables can cause FlatSharp to emit thousands of lines of code. This is repeated whenever a large table is part of more than one root type. This most prominently becomes a problem with gRPC definitions, which have many different root types for Request/Response scenarios. Such duplication can lead to poor utilization of CPU cache/branch predictors, in addition to being more generally wasteful.
Unfortunately, This may require dropping support for Greedy
and GreedyMutable
deserialization modes as this can interfere with the above. Scenarios like WriteThrough are a key feature of FlatBuffers, but are also completely nonsensical with Greedy serialization, so FlatSharp would either need to drop Greedy deserialization or fail at runtime instead of compile time. Neither is ideal.
.NET 7
The upcoming .NET 7 release provides some opportunities to emit better code:
- Required properties
- Static abstract interface members (
IFlatBufferSerializable
)