-
Notifications
You must be signed in to change notification settings - Fork 2
Add Char Type support #164
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
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.
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 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
CharProtoParserfor 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
This comment has been minimized.
This comment has been minimized.
|
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