Skip to content

feat(codegen): reflection-free Compact Binary serialization - #22

Merged
mircodz merged 3 commits into
mainfrom
codegen-serde
Oct 1, 2026
Merged

mircodz merged 3 commits into
mainfrom
codegen-serde

Conversation

@mircodz

@mircodz mircodz commented Oct 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

`--serialization` (MSBuild: `BondSerialization`) generates Compact Binary v1
serialization for every struct, backed by the new BondTools.Runtime package:

- `order.Serialize()` and `Order.Deserialize(bytes)`, with IBufferWriter<byte>,
  ReadOnlySequence<byte> and Stream overloads; IBondStruct<T> for generic code
- generic structs, which take a codec (BondCodec) per type parameter
- bonded<T>, read as BondedPayload<T> and written back unchanged
- custom type mappings, converted by BondTypeAliasConverter as with gbc

It writes the bytes upstream Bond writes and reads any payload, valid or not,
as upstream Bond reads it: the tests compare both runtimes on fixed, boundary,
malformed and mutated payloads. It is 1.3-4x faster than Bond.Runtime.CSharp
on most payloads; benchmarks/ (outside Bond.sln) compares the two.
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Coverage Report

Line Coverage: 89.5%
Branch Coverage: 83.8%

View detailed coverage
Summary
  Generated on: 10/01/2026 - 21:54:43
  Coverage date: 10/01/2026 - 21:54:14 - 10/01/2026 - 21:54:41
  Parser: MultiReport (2x Cobertura)
  Assemblies: 2
  Classes: 68
  Files: 55
  Line coverage: 89.5%
  Covered lines: 4111
  Uncovered lines: 479
  Coverable lines: 4590
  Total lines: 9809
  Branch coverage: 83.8% (3177 of 3789)
  Covered branches: 3177
  Total branches: 3789
  Method coverage: 82.1% (548 of 667)
  Covered methods: 548
  Total methods: 667
  Tag: 81_36931579237

Bond.Parser                                            91.0%
  Bond.Parser.CodeGeneration.CSharpGenerationOptions  100.0%
  Bond.Parser.CodeGeneration.CSharpGenerationResult   100.0%
  Bond.Parser.CodeGeneration.CSharpGenerator           94.3%
  Bond.Parser.Compatibility.CompatibilityChecker       95.2%
  Bond.Parser.Compatibility.CompatibilityOptions      100.0%
  Bond.Parser.Compatibility.CompatibilityResult       100.0%
  Bond.Parser.Compatibility.ContractDeclaration       100.0%
  Bond.Parser.Compatibility.ContractField             100.0%
  Bond.Parser.Compatibility.DiagnosticIds             100.0%
  Bond.Parser.Compatibility.SchemaChange               36.8%
  Bond.Parser.Compatibility.SchemaContract            100.0%
  Bond.Parser.Compatibility.SchemaContractBuilder      96.1%
  Bond.Parser.Compatibility.SchemaContractValidation   97.8%
  Bond.Parser.Compatibility.TypeShape                 100.0%
  Bond.Parser.Formatting.BondFormatter                 82.2%
  Bond.Parser.Formatting.FormatResult                 100.0%
  Bond.Parser.Json.AttributeJsonConverter             100.0%
  Bond.Parser.Json.BondJsonConverter                  100.0%
  Bond.Parser.Json.BondJsonSerializerOptions           82.3%
  Bond.Parser.Json.BondTypeJsonConverter               97.9%
  Bond.Parser.Json.ConstantJsonConverter              100.0%
  Bond.Parser.Json.DeclarationJsonConverter            95.8%
  Bond.Parser.Json.DefaultJsonConverter                95.6%
  Bond.Parser.Json.FieldJsonConverter                  95.6%
  Bond.Parser.Json.ImportJsonConverter                100.0%
  Bond.Parser.Json.MethodJsonConverter                 96.7%
  Bond.Parser.Json.MethodTypeJsonConverter             85.7%
  Bond.Parser.Json.NamespaceJsonConverter              75.0%
  Bond.Parser.Json.TypeParamJsonConverter             100.0%
  Bond.Parser.Json.WriteOnlyJsonConverter<T>            0.0%
  Bond.Parser.Parser.AstBuilder                        95.5%
  Bond.Parser.Parser.DefaultImportResolver            100.0%
  Bond.Parser.Parser.ErrorListener                    100.0%
  Bond.Parser.Parser.ParseError                       100.0%
  Bond.Parser.Parser.ParseErrorsException             100.0%
  Bond.Parser.Parser.ParseResult                      100.0%
  Bond.Parser.Parser.ParserFacade                      86.0%
  Bond.Parser.Parser.SemanticAnalyzer                  91.3%
  Bond.Parser.Parser.SemanticErrorException           100.0%
  Bond.Parser.Parser.SymbolTable                       86.6%
  Bond.Parser.Parser.TypeResolver                      84.9%
  Bond.Parser.Parser.TypeValidator                     92.0%
  Bond.Parser.Syntax.AliasDeclaration                   0.0%
  Bond.Parser.Syntax.Attribute                         80.0%
  Bond.Parser.Syntax.Bond                              83.3%
  Bond.Parser.Syntax.BondType                          68.6%
  Bond.Parser.Syntax.BondTypeExtensions                93.7%
  Bond.Parser.Syntax.Constant                          80.0%
  Bond.Parser.Syntax.Declaration                      100.0%
  Bond.Parser.Syntax.Default                           33.3%
  Bond.Parser.Syntax.EnumDeclaration                    0.0%
  Bond.Parser.Syntax.EventMethod                        0.0%
  Bond.Parser.Syntax.Field                             50.0%
  Bond.Parser.Syntax.ForwardDeclaration                25.0%
  Bond.Parser.Syntax.FunctionMethod                     0.0%
  Bond.Parser.Syntax.Import                             0.0%
  Bond.Parser.Syntax.MethodType                        50.0%
  Bond.Parser.Syntax.Namespace                         66.6%
  Bond.Parser.Syntax.ServiceDeclaration                 0.0%
  Bond.Parser.Syntax.SourceLocation                     0.0%
  Bond.Parser.Syntax.StructDeclaration                 16.6%
  Bond.Parser.Syntax.TypeParam                         80.0%
  Bond.Parser.Util.Extensions                         100.0%

BondTools.Runtime                                      76.4%
  BondTools.Runtime.BondCodec                          41.6%
  BondTools.Runtime.BondedPayload<T>                   90.0%
  BondTools.Runtime.CompactBinary                     100.0%
  BondTools.Runtime.CompactBinaryReader                96.6%
  BondTools.Runtime.CompactBinaryWriter                98.6%

Coverage report generated for commit fd4f92a

@mircodz
mircodz merged commit aa5339e into main Oct 1, 2026
2 checks passed
@mircodz
mircodz deleted the codegen-serde branch October 1, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant