-
Notifications
You must be signed in to change notification settings - Fork 2
Write Super Long Message Support(int.MaxValue to long.MaxValue) #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
- Coverage 97.88% 97.59% -0.29%
==========================================
Files 114 114
Lines 2365 2497 +132
Branches 267 280 +13
==========================================
+ Hits 2315 2437 +122
- Misses 30 38 +8
- Partials 20 22 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for serializing messages larger than int.MaxValue (2GB) by introducing CalculateLongSize methods throughout the codebase that return long instead of int.
Changes:
- Added
CalculateLongSize(long)methods toIProtoWriterandIProtoWriter<T>interfaces - Implemented
CalculateLongSizein all built-in parser types (primitives, collections, wrappers) - Updated code generator to emit
CalculateLongSizemethods for generated types - Added infrastructure methods
WriteLongLength,ComputeLongLengthSizefor writing long lengths - Added comprehensive tests including a test that creates a 5GB message to verify the functionality
Reviewed changes
Copilot reviewed 64 out of 64 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/LightProto/IProtoParser.cs | Added CalculateLongSize methods to IProtoWriter interfaces |
| src/LightProto/WriterContext.cs | Added WriteLongLength method for writing long length values |
| src/LightProto/WritingPrimitives.cs | Added WriteLongLength implementation |
| src/LightProto/CodedOutputStream.ComputeSize.cs | Added ComputeLongLengthSize for calculating varint size of long values |
| src/LightProto/RuntimeProtoWriter.cs | Implemented CalculateLongSize with overflow checking |
| src/LightProto/Serializer.*.cs | Updated serialization methods to use long sizes |
| src/LightProto/Parser/*.cs | Implemented CalculateLongSize in all parser types |
| src/LightProto.Generator/LightProtoGenerator.cs | Updated code generator to emit CalculateLongSize methods |
| tests/LightProto.Tests/LongLengthMessageTests.cs | New test for messages exceeding int.MaxValue |
| tests/LightProto.Tests/CollectionTest/*.cs | Added tests to verify CalculateLongSize returns same value as CalculateSize for small objects |
| tests/LightProto.Tests/CustomParser/*.cs | Updated custom parsers to implement CalculateLongSize |
| src/LightProto/PublicAPI/*.txt | Documented new public API surface |
This comment has been minimized.
This comment has been minimized.
Refactored size calculation methods to consistently use long-based calculations and removed redundant overflow checks. Added overflow checks and exceptions for serialization methods that could exceed array or prefix size limits. Expanded test coverage for large messages, including overflow scenarios and additional assertions for size calculation consistency.
Replaces calls to CalculateLongSize with CalculateSize in LongLengthMessageTests to reflect updated method naming or API changes.
This comment has been minimized.
This comment has been minimized.
Wrapped LongLengthMessageTest in a .NET 10 conditional to avoid out-of-memory issues in CI. Increased the number of items but reduced the size of each item's data to lower overall memory usage. Added explicit GC.Collect call and updated assertions accordingly.
This comment has been minimized.
This comment has been minimized.
Updated LongLengthMessageTests to include assertions for OverflowException when calculating sizes for large messages. Fixed a typo in the preprocessor directive for .NET 10. Added a KeyValuePair test case in NonGenericSerializerTests. Corrected method usage in IntergrationTests for CalculateLongSize.
|
No description provided.