FlatSharp.Runtime is the runtime component of FlatSharp that supports code emitted by the FlatSharp.Compiler package.
$ dotnet add package FlatSharp.RuntimeThanks for using FlatSharp! FlatSharp is a C# FlatBuffers implementation designed to be secure, fast, and easy to use.
FlatSharp is open source. Find it on GitHub! Issues, contributions, and other feedback are always welcome. Don't be a stranger! If you have feedback to share, please consider filling out the form here!
FlatSharp is free and always will be. However, the project does take a significant amount of time to maintain. If you or your organization find the project useful, please consider a Github sponsorship. Any amount is appreciated!
Reference both FlatSharp.Runtime and FlatSharp.Compiler. Use the same version for them both.
// all FlatSharp FBS attributes start with the 'fs_' prefix.
attribute "fs_serializer";
namespace MyNamespace;
enum Color : ubyte { Red = 1, Green, Blue }
table Person (fs_serializer) {
Id:int;
Name:string;
Parent:Person (deprecated);
Children:[Person];
FavoriteColor:Color = Blue;
Position:Location;
}
struct Location {
Latitude:float;
Longitude:float;
}
<ItemGroup>
<FlatSharpSchema Include="YourSchema.fbs" />
</ItemGroup>
Person person = new Person(...);
int maxBytesNeeded = Person.Serializer.GetMaxSize(person);
byte[] buffer = new byte[maxBytesNeeded];
int bytesWritten = Person.Serializer.Serialize(buffer, person);
Person p = Person.Serializer.Parse(data);
FlatSharp is licensed under Apache 2.0. Have fun :)