Repository navigation
Conversation
`--clear` (MSBuild: `BondClear`) generates Clear(), which resets every field to the default the constructor gives it. Collections are emptied and structs from the same file are cleared in place, so a cleared instance keeps its storage for the next read; structs from other files are replaced.
Deserialize(data, into), for spans, sequences and streams, reads into the given instance as Bond merges: the payload's fields replace the instance's, nested structs are read into its own and container elements are appended. After Clear(), the instance reads as a new one would, keeping its storage.
Each read also runs as Clear() followed by Deserialize(bytes, into), in the same category, so reuse shows next to a new instance.
The README's read table gets a column for reads into a reused instance.
The runtime README links to them, and benchmarks/RESULTS.md becomes benchmarks/README.md, which GitHub shows with the folder. The i7 numbers are rerun, pinned away from a busy core.
Code Coverage ReportLine Coverage: 80.8% View detailed coverageCoverage report generated for commit 8acdccf |
There was a problem hiding this comment.
🟡 Changes recommended
Generic nested values bypass reuse, and the new abstract interface members break existing implementations.
5 open findings
Static abstract members break existing IBondStruct implementations · New Type-parameter fields bypass into-aware codec reads · New Validate span arguments before materializing multi-segment sequences · New Validate stream arguments before consuming the stream · New Document limits of nested storage reuse guarantees · New
What changed in this PR
Adds generated model clearing and deserialize-into APIs to support instance reuse and object pooling.
Changes:
- Adds optional
Clear()generation through CLI and MSBuild. - Adds runtime and generated deserialization-into-existing-instance APIs.
- Expands tests, benchmarks, documentation, dependencies, and package versioning.
| File | Description |
|---|---|
version |
Bumps version to 1.7.0. |
tests/Bond.Parser.Tests/CSharpSerializationTests.cs |
Tests deserialize-into overloads. |
tests/Bond.Parser.Tests/CSharpModelFeatureTests.cs |
Tests generated clearing behavior. |
tests/Bond.Build.Tests/MsBuildGenerationTests.cs |
Tests MSBuild clear generation. |
README.md |
Documents CLI usage and performance. |
Directory.Packages.props |
Updates dependencies. |
Bond.Runtime/README.md |
Documents instance reuse. |
Bond.Runtime/IBondStruct.cs |
Extends the serialization interface. |
Bond.Runtime/CompactBinary.cs |
Adds deserialize-into overloads. |
Bond.Runtime/BondCodec.cs |
Adds into-aware codec reading. |
Bond.Parser/CodeGeneration/CSharpSerializationEmitter.cs |
Generates deserialize-into APIs. |
Bond.Parser/CodeGeneration/CSharpModelEmitter.cs |
Generates Clear() implementations. |
Bond.Parser/CodeGeneration/CSharpGenerationOptions.cs |
Adds the clearing feature flag. |
Bond.Parser.CLI/Program.cs |
Adds --clear. |
Bond.Build/README.md |
Documents BondClear. |
Bond.Build/GenerateBond.cs |
Reads clear-generation metadata. |
Bond.Build/build/BondTools.Build.targets |
Forwards BondClear. |
benchmarks/RESULTS.md |
Removes the former results file. |
benchmarks/README.md |
Adds updated benchmark results. |
benchmarks/Benchmarks.csproj |
Enables clearing in benchmark codegen. |
benchmarks/Benchmarks.cs |
Benchmarks reused deserialization. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+135
to
+139
| Line(3, $"public override {self} Read(ref {Runtime}CompactBinaryReader reader, {Runtime}WireType type, {self} into)"); | ||
| Line(3, "{"); | ||
| Line(4, $"{Runtime}CompactBinaryReader.Expect(type, {Runtime}WireType.Struct);"); | ||
| Line(4, $"return {self}.Read(ref reader, into{_codecArguments});"); | ||
| Line(3, "}"); |
|
|
||
| ## Reusing instances | ||
|
|
||
| `Deserialize(bytes, into)` reads into an existing instance, as Bond merges: the payload's fields replace the instance's, nested structs are read into the instance's own, and container elements are appended. With `--clear`, clearing first reads it as a new instance would, while keeping its lists and nested structs, so only strings and new elements are allocated: |
Add null checks for input, into, and codec parameters. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Added null checks for 'into' and 'codec' parameters in Deserialize method. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.