Support byte[] BSON binary and add tests#29
Merged
mrdevrobot merged 2 commits intomainfrom Mar 31, 2026
Merged
Conversation
Add full byte[] (BSON Binary) support to the source generator and tests. Map byte[] to WriteBinary/ReadBinary in CodeGenerator, handle ReadBinary's ReadOnlySpan<byte> by calling .ToArray(), and add null handling for nullable byte[] properties. Exclude byte[] from being treated as a sequence in SyntaxHelper. Add BinaryEntity model and register the collection in TestDbContext, and introduce comprehensive BinaryPropertyTests covering round-trips, empty arrays, nullable fields, updates, persistence across reopen, large payloads, BLiteEngine (dynamic/BSON) interop, and JSON base64 behavior.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for mapping byte[] properties to BSON Binary in the BLite source generator, with new tests that validate typed/dynamic round-trips and nullable handling.
Changes:
- Extend source generator primitive handling to write/read
byte[]as BSON Binary (including nullable cases). - Exclude
byte[]from being treated as a generic collection/array during analysis. - Add
BinaryEntity+BinaryEntitiescollection and a comprehensiveBinaryPropertyTestssuite.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/BLite.SourceGenerators/CodeGenerator.cs |
Adds byte[] primitive mapping to WriteBinary/ReadBinary and ensures binary reads materialize spans via ToArray(). |
src/BLite.SourceGenerators/Helpers/SyntaxHelper.cs |
Prevents byte[] from being classified as a collection type. |
tests/BLite.Shared/MockEntities.cs |
Introduces BinaryEntity with required + optional binary fields for testing. |
tests/BLite.Shared/TestDbContext.cs |
Registers BinaryEntities collection and maps BinaryEntity to binary_entities. |
tests/BLite.Tests/BinaryPropertyTests.cs |
Adds extensive tests for byte[] persistence, updates, reopen durability, dynamic↔typed compatibility, and JSON caveats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/EntglDb/BLite/sessions/29b1ef90-8d5e-487d-b058-6b6ca476f085 Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com>
Contributor
Applied all four review suggestions in commit a466b22:
|
This was referenced Apr 1, 2026
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.
DeleteFileIfExistshelperBinaryProperty_PersistsAcrossReopencleanup to also delete WAL fileBinaryProperty_BLiteEngine_WritesBsonBinary_TypedReaderGetsBytescleanup to also delete WAL fileIsValidJsonto disposeJsonDocumentwithusing varto avoid pooled buffer leaksDeleteFileIfExistshelper and use it consistently throughout all cleanup code