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

Skip to content

Conversation

@dameng324
Copy link
Owner

@dameng324 dameng324 commented Jan 15, 2026

Introduces CharProtoParser for handling char serialization and deserialization. Updates generator, packed repeated logic, and dynamic serializer registration to support char. Adds tests for char fields and collections, and updates public API files. Also updates test project dependencies and test coverage for char handling.

Fixes: #161

Introduces CharProtoParser for handling char serialization and deserialization. Updates generator, packed repeated logic, and dynamic serializer registration to support char. Adds tests for char fields and collections, and updates public API files. Also updates test project dependencies and test coverage for char handling.
Copilot AI review requested due to automatic review settings January 15, 2026 05:50
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 PR adds support for the char type to LightProto by introducing CharProtoParser for handling char serialization and deserialization. It updates the generator to recognize char types, adds packed repeated support, registers the parser dynamically, and includes comprehensive tests for char fields and collections.

Changes:

  • Adds CharProtoParser for char type serialization/deserialization with varint encoding
  • Updates generator to support char with varint wire type and extends packed repeated logic
  • Adds test coverage for char values (both varint and fixed32 formats) and char collections
  • Updates TUnit version and removes multi-framework testing (net8.0, net9.0) in favor of net10.0 only

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/LightProto/Parser/Char.cs New parser for char type using varint/uint32 encoding
src/LightProto/Serializer.Dynamically.cs Registers CharProtoParser for dynamic serialization
src/LightProto/PackedRepeated.cs Adds char to packed repeated types
src/LightProto.Generator/LightProtoGenerator.cs Adds char wire type support (varint only)
src/LightProto/PublicAPI/*.txt Documents new public API for CharProtoParser
tests/LightProto.Tests/Parsers/PrimitiveTests.cs Adds tests for char fields (both varint and fixed size)
tests/LightProto.Tests/Parsers/PrimitiveArrayTests.cs Adds tests for char arrays/collections
tests/LightProto.Tests/NonGenericSerializerTests.cs Adds char to dynamic serializer tests
tests/LightProto.Tests/CollectionTest/CollectionTests.cs Adds char collection test
tests/LightProto.Tests/Parsers/parser.proto Adds proto definitions for char testing
tests/LightProto.Tests/LightProto.Tests.csproj Updates TUnit version and changes target frameworks
tests/LightProto.AssemblyLevelTests/LightProto.AssemblyLevelTests.csproj Removes duplicate TUnit reference
Comments suppressed due to low confidence (3)

src/LightProto.Generator/LightProtoGenerator.cs:1

  • The TryGetInternalTypeName method needs to handle char type with FixedSize format. Add this case after line 1288 (or modify the switch to include it). Without this, the generator won't properly map char fields with DataFormat.FixedSize to the correct parser.
using System.Collections.Immutable;

src/LightProto.Generator/LightProtoGenerator.cs:1

  • The GetProtoParser method needs to handle char with FixedSize format in the switch expression starting at line 1570. Add a case for SpecialType.System_Char when format is DataFormat.FixedSize => \"FixedChar\", to properly resolve the parser name for fixed-size char fields.
using System.Collections.Immutable;

src/LightProto.Generator/LightProtoGenerator.cs:2015

  • The GetFixedSize method (line 2015) needs to include System_Char when dataFormat is DataFormat.FixedSize to return 4. Without this, packed fixed-size char arrays may not calculate their size correctly.
            or SpecialType.System_Byte when dataFormat is DataFormat.FixedSize => 4,

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.76%. Comparing base (f6f64b1) to head (0dfb253).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #164   +/-   ##
=======================================
  Coverage   98.75%   98.76%           
=======================================
  Files         105      106    +1     
  Lines        2497     2512   +15     
  Branches      250      250           
=======================================
+ Hits         2466     2481   +15     
  Misses         19       19           
  Partials       12       12           

☔ 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.

Modified test project files to target only net10.0 in non-Release builds and net8.0, net9.0, net10.0 (plus net48 on Windows) in Release builds. This change optimizes build configurations for development and release scenarios.
Removed the private constructor from CharProtoParser, making it publicly instantiable. Updated PublicAPI files to reflect the new public constructor.
@github-actions

This comment has been minimized.

@github-actions
Copy link


BenchmarkDotNet v0.15.3, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.101
  [Host]    : .NET 8.0.22 (8.0.22, 8.0.2225.52707), 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.22 (8.0.22, 8.0.2225.52707), 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 757.5 μs 1.95 μs 1.73 μs 1.34 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 10.0 .NET 10.0 608.4 μs 1.97 μs 1.65 μs 1.08 648.7 KB 1.13
Deserialize_LightProto .NET 10.0 .NET 10.0 565.9 μs 2.70 μs 2.39 μs 1.00 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 8.0 .NET 8.0 888.2 μs 2.45 μs 2.17 μs 1.52 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 8.0 .NET 8.0 798.5 μs 1.95 μs 1.82 μs 1.36 648.7 KB 1.13
Deserialize_LightProto .NET 8.0 .NET 8.0 585.2 μs 2.57 μs 2.15 μs 1.00 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 9.0 .NET 9.0 826.3 μs 2.63 μs 2.33 μs 1.44 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 9.0 .NET 9.0 715.7 μs 5.09 μs 4.76 μs 1.25 648.7 KB 1.13
Deserialize_LightProto .NET 9.0 .NET 9.0 572.7 μs 2.53 μs 2.11 μs 1.00 574.8 KB 1.00

BenchmarkDotNet v0.15.3, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.101
  [Host]    : .NET 8.0.22 (8.0.22, 8.0.2225.52707), 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.22 (8.0.22, 8.0.2225.52707), 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 932.7 μs 2.40 μs 2.00 μs 1.36 526.41 KB 1.03
Serialize_GoogleProtoBuf .NET 10.0 .NET 10.0 786.5 μs 2.69 μs 2.52 μs 1.15 512.95 KB 1.00
Serialize_LightProto .NET 10.0 .NET 10.0 685.5 μs 1.90 μs 1.59 μs 1.00 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 8.0 .NET 8.0 1,025.6 μs 2.86 μs 2.53 μs 1.36 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 8.0 .NET 8.0 818.7 μs 3.17 μs 2.81 μs 1.09 512.95 KB 1.00
Serialize_LightProto .NET 8.0 .NET 8.0 753.3 μs 3.33 μs 2.95 μs 1.00 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 9.0 .NET 9.0 959.7 μs 1.72 μs 1.60 μs 1.28 526.41 KB 1.03
Serialize_GoogleProtoBuf .NET 9.0 .NET 9.0 813.8 μs 1.37 μs 1.22 μs 1.09 512.95 KB 1.00
Serialize_LightProto .NET 9.0 .NET 9.0 749.2 μs 1.99 μs 1.76 μs 1.00 512.92 KB 1.00

@dameng324 dameng324 merged commit 4d7edf1 into main Jan 15, 2026
8 checks passed
@dameng324 dameng324 deleted the add-char-support branch January 15, 2026 06:34
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.

Add Char support

2 participants