Releases: jamescourtney/FlatSharp
7.9.0
7.9.0
FlatSharp 7.9.0 is a relatively minor release in the 7.X tree. While work is going (slowly) on FlatSharp 8 as time permits, my intent is for the 7.X line to receive ports for viable changes that would have otherwise been only for FlatSharp 8.
- The generate methods compiler option now emits operator overloads for value struct equality.
- Unions and their members now have
[FlatBufferMetadata]attributes emitted. - Pretty printing is now disabled by default for generated code. This makes the FlatSharp compiler considerably faster at the cost of slightly uglier generated code. This can be re-enabled via a compiler switch.
- Support for partial properties in tables and reference structs via the
fs_partialPropertyannotation. - Fix a bug in the runtime detection logic in the targets file.
What's Changed
- Change workflow to trigger on PR on any branch by @trumully in #453
- Struct equality by @trumully in #452
- Update macos runner by @trumully in #465
- Add option to enable pretty print - disabled by default by @trumully in #463
- Emit attributes for union values by @trumully in #462
- Add Fuzz Tests by @jamescourtney in #470
- Basic partial properties by @jamescourtney in #469
- Extra stuff for partial properties by @jamescourtney in #471
- Rev version to 7.9 (#473) by @jamescourtney in #475
- Fix runtime detection in targets file (#477) by @jamescourtney in #478
Full Changelog: 7.8.0...7.9.0
7.8.0
FlatSharp 7.8.0 contains a small number of new features and bugfixes thanks to @sssooonnnggg and @trumully! Thank you for the contributions!
Features
- Unions can how have manually set discriminator values, ie
union MyUnion { str : string = 3, MyTable = 6 } - Using the
<FlatSharpGenerateMethods>true</FlatSharpGenerateMethods>in your .csproj file now allows generating.ToString()methods on certain FlatSharp objects. More in the future! - Builds targeting .NET 9 (no .NET 9 features used yet)
Fixes
- Fix an issue where
\and"characters were not escaped when present in a FlatBuffer attribute value.
Other Changes
- Removal of the FlatSharp object pooling experimental feature.
What's Changed
- Fix pipelines by @jamescourtney in #446
- chore: create output directory if not exists by @sssooonnnggg in #444
- fix: emit attribute with escaped quote and backslash by @sssooonnnggg in #445
- fix: fixed union generator when processing union with custom enum value by @sssooonnnggg in #447
- Add net 9 by @jamescourtney in #449
- Remove Object Pooling by @jamescourtney in #450
- Add ToString methods by @trumully in #437
New Contributors
- @sssooonnnggg made their first contribution in #444
Full Changelog: 7.7.0...7.8.0
7.7.0
FlatSharp 7.7.0 is a small feature release. Thanks to @trumully and @parched, unions now have implicit operators for assignment:
SomeUnion union = "hello";Thanks for the contribution!
Additionally, a bug has been fixed relating to use of the required modifier with various setter options. Previous versions of FlatSharp would generate invalid C# if using required with a non-public setter. The new behavior is to always enforce the concept of required when serializing/parsing, but to only add the C# required keyword to a property when the setter's visibility is public.
What's Changed
- Fix required properties by @jamescourtney in #439
- Add implicit operator to Union types by @trumully in #438
New Contributors
Full Changelog: 7.6.0...7.7.0
7.6.0
FlatSharp 7.6.0 is a small feature release that adds a couple of quality of life features:
-
New
Matchmethods on Union types that accept delegates. These aren't the most performant but work well for one-offs or cases where you don't want to implement a Visitor. -
Optional support for
filevisibility on types in FlatSharp-generated code. This reduces the clutter you'll see in your code from FlatSharp. Since file visibility is only supported on C# 11 and above, you will need to opt into this behavior:<PropertyGroup> <FlatSharpFileVisibility>true</FlatSharpFileVisibility> </PropertyGroup>
From the command line:
dotnet FlatSharp.Compiler.dll --file-visibility
In addition to these features, FlatSharp's primary unit tests now all run in NativeAOT mode as well as JIT mode thanks to the new NativeAOT-compatible MSTest runner.
What's Changed
- Update Samples for 7.5 by @jamescourtney in #429
- Add union match method by @jamescourtney in #430
- Update build system by @jamescourtney in #431
- Convert E2E Tests to use MSTest to enable NativeAOT unit testing by @jamescourtney in #432
- Refactor Benchmarks to work with AOT by @jamescourtney in #433
- Build refactor by @jamescourtney in #434
- Add file visibility option by @jamescourtney in #435
Full Changelog: 7.5.1...7.6.0
7.5.1
FlatSharp 7.5.1 is a minor release that contains important fixes for NativeAOT support.
- Fix .NET 8 Native AOT, Mono AOT, and add CI pipelines to ensure these don't regress again in the future.
- Remove some methods from
IInputBufferandISpanWriterthat led to the issues with AOT.
What's Changed
- Native aot stuff by @jamescourtney in #425
- Add some nativeaot test cases by @jamescourtney in #426
- Mono AOT Validation by @jamescourtney in #427
- Update packages and SpanWriter by @jamescourtney in #428
Full Changelog: 7.5.0...7.5.1
7.5.0
FlatSharp 7.5.0 is a medium-sized release with a few changes that may be significant for you. It's now published on Nuget.org. There are no breaking changes.
The primary focus of this release is to significantly reduce the size of the x64 assembly produced by the JITer. There are 3 ways that this is accomplished:
-
String serialization is no longer inlined. This reduces code size substantially but does have a modest impact on serialization speed. There are other changes that offset most of the performance loss. However, FlatSharp should play much more nicely with your instruction cache now.
-
Using
ThrowHelper-style methods for throwing exceptions from hot paths. -
Remove most
checkedarithmetic. FlatSharp already uses safe methods for interacting with memory. The onlycheckedoperations that remain are multiplications and left shifts. This removes many branch instructions and further compacts the generated assembly. If you have a security need to retaincheckedarithmetic everywhere, please consider compiling with<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>in yourcsproj.
How much of a difference does this make? Let's look at a contrived example:
table MailingAddress (fs_serializer)
{
to : string;
street : string;
city : string;
zip_code : int;
}Examining the bytes of code generated to serialize this results in:
| Version | Performance | Table Serialize Bytes | String Serialize Bytes | Total |
|---|---|---|---|---|
| 7.4.0 | 60ns | 3888 (inlined) | 0 | 3888 |
| 7.5.0 | 58ns | 988 (method calls) | 550 | 1538 |
This effect will scale for each string property in your schema, so while this example is contrived, the benefit should be large for applications where strings are a common data type.
Note: The focus is on shrinking the size of the code generated by the JIT. The generated C# is largely unchanged.
There are some other changes as well:
- Add README.md files to the FlatSharp NuGet packages.
- Add the
[DebuggerTypeProxy]attribute to all generated classes. This ensures that much of the internal FlatSharp state is excluded from debugging views and makes the debugging experience more seamless.
What's Changed
- Update samples to latest by @jamescourtney in #413
- Refactor exceptions and string concat by @jamescourtney in #420
- Reduce JIT'ed Code Size and Optimize by @jamescourtney in #421
- Add NuGet READMEs by @jamescourtney in #422
- Add [DebuggerTypeProxy] to generated classes. by @jamescourtney in #423
- Give reference unions the exception treatment by @jamescourtney in #424
Full Changelog: 7.4.0...7.5.0
7.4.0
FlatSharp 7.4.0 is available on Nuget with a couple of nonbreaking changes:
FlatSharp.Runtimesupports .NET 8FlatSharp.Compilernow requires any of .NET 8, .NET 7, or .NET 6 to be installed (previously it supported only .NET 6).- Fixes a bug where FlatSharp generated invalid code if
FlatSharpwas declared as a non-top-level namespace, such asFoo.Bar.FlatSharp.
What's Changed
- Update Google flatbuffers, add verify tests by @jamescourtney in #394
- Add Stryker Tests to Code Coverage by @jamescourtney in #397
- Delete Legacy Tests by @jamescourtney in #398
- Metadata attributes by @jamescourtney in #403
- Add global namespace test by @jamescourtney in #409
- Net8 by @jamescourtney in #412
Full Changelog: 7.2.3...7.4.0
7.2.3
FlatSharp 7.2.3 is a small release that fixes a few issues:
- FBS validation issues
- Issue where FBS files couldn't be loaded when on different drives on Windows systems
- Cleanup of FlatSharp Unit Tests
7.2.0
7.2.0 is a minor feature release that resolves a few bugs and adds a small number of enhancements to the FlatSharp compiler package.
New Compiler Switches
Select Deserializers
You can now select deserializers FlatSharp should generate. This allows some degree of control over code size from FlatSharp:
<PropertyGroup>
<FlatSharpDeserializers>Lazy;Greedy</FlatSharpDeserializers>
</PropertyGroup>Using the command line, you can pass --deserializers Progressive;GreedyMutable
Class Definitions Only
In the same vein, FlatSharp can be configured to only emit class definitions. This allows sharing a set of common schemas between projects.
<PropertyGroup>
<FlatSharpClassDefinitionsOnly>true</FlatSharpClassDefinitionsOnly>
</PropertyGroup>Using the command line, you can pass --class-definitions-only.
Input Files Only
Normally, FlatSharp will process all FBS files in the recursive graph, including include references that were not explicitly passed to FlatSharp. With this switch, FlatSharp can be configured to only emit output for explicitly-passed input files.
<PropertyGroup>
<FlatSharpInputFilesOnly>true</FlatSharpInputFilesOnly>
</PropertyGroup>Using the command line, you can pass --input-files-only.
Other Enhancements
7.2.0 includes a small set of quality-of-life enhancements:
- The set of command line options is now part of the file hash in the generated file header. This will make FlatSharp regenerate .cs files when the command line options have changed.
- All generated classes and vectors now have
[DebuggerDisplay]attributes to make using the debugger a little less cumbersome. - Bug #384 should now be fixed.