Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dameng324
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 26, 2026 08:19
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 96.91358% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.59%. Comparing base (ff7b916) to head (a50758f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/LightProto/Parser/MessageWrapper.cs 66.66% 1 Missing and 1 partial ⚠️
src/LightProto/Parser/MessageWrapper_T.cs 71.42% 1 Missing and 1 partial ⚠️
src/LightProto/Parser/Nullable.cs 83.33% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a 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 to IProtoWriter and IProtoWriter<T> interfaces
  • Implemented CalculateLongSize in all built-in parser types (primitives, collections, wrappers)
  • Updated code generator to emit CalculateLongSize methods for generated types
  • Added infrastructure methods WriteLongLength, ComputeLongLengthSize for 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

@github-actions

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.
@github-actions

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.
@github-actions

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.
@dameng324 dameng324 merged commit 2772a4c into main Jan 26, 2026
8 checks passed
@dameng324 dameng324 deleted the super-long-message-write-support branch January 26, 2026 10:13
@github-actions
Copy link


BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.102
  [Host]    : .NET 8.0.23 (8.0.23, 8.0.2325.60607), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3
  .NET 8.0  : .NET 8.0.23 (8.0.23, 8.0.2325.60607), X64 RyuJIT x86-64-v3
  .NET 9.0  : .NET 9.0.12 (9.0.12, 9.0.1225.60609), X64 RyuJIT x86-64-v3


Method Job Runtime Mean Error StdDev Ratio Allocated Alloc Ratio
Deserialize_ProtoBuf_net .NET 10.0 .NET 10.0 764.6 μs 2.42 μs 2.15 μs 1.28 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 10.0 .NET 10.0 612.0 μs 1.33 μs 1.04 μs 1.03 648.7 KB 1.13
Deserialize_LightProto .NET 10.0 .NET 10.0 595.4 μs 1.22 μs 1.08 μs 1.00 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 8.0 .NET 8.0 918.2 μs 1.58 μs 1.32 μs 1.50 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 8.0 .NET 8.0 798.5 μs 2.93 μs 2.74 μs 1.31 648.7 KB 1.13
Deserialize_LightProto .NET 8.0 .NET 8.0 610.5 μs 1.52 μs 1.27 μs 1.00 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 9.0 .NET 9.0 832.1 μs 3.59 μs 3.18 μs 1.32 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 9.0 .NET 9.0 705.3 μs 3.91 μs 3.26 μs 1.11 648.7 KB 1.13
Deserialize_LightProto .NET 9.0 .NET 9.0 632.7 μs 1.90 μs 1.59 μs 1.00 574.8 KB 1.00

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.102
  [Host]    : .NET 8.0.23 (8.0.23, 8.0.2325.60607), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3
  .NET 8.0  : .NET 8.0.23 (8.0.23, 8.0.2325.60607), X64 RyuJIT x86-64-v3
  .NET 9.0  : .NET 9.0.12 (9.0.12, 9.0.1225.60609), X64 RyuJIT x86-64-v3


Method Job Runtime Mean Error StdDev Ratio Allocated Alloc Ratio
Serialize_ProtoBuf_net .NET 10.0 .NET 10.0 894.5 μs 2.28 μs 2.02 μs 1.27 526.41 KB 1.03
Serialize_GoogleProtoBuf .NET 10.0 .NET 10.0 780.7 μs 1.96 μs 1.64 μs 1.11 512.95 KB 1.00
Serialize_LightProto .NET 10.0 .NET 10.0 706.1 μs 1.01 μs 0.94 μs 1.00 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 8.0 .NET 8.0 1,017.8 μs 3.31 μs 2.93 μs 1.32 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 8.0 .NET 8.0 834.7 μs 1.44 μs 1.28 μs 1.08 512.95 KB 1.00
Serialize_LightProto .NET 8.0 .NET 8.0 770.9 μs 1.81 μs 1.60 μs 1.00 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 9.0 .NET 9.0 980.8 μs 2.98 μs 2.79 μs 1.29 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 9.0 .NET 9.0 829.8 μs 3.49 μs 3.10 μs 1.10 512.95 KB 1.00
Serialize_LightProto .NET 9.0 .NET 9.0 757.4 μs 3.38 μs 3.00 μs 1.00 512.92 KB 1.00

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.

2 participants