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

Skip to content

Conversation

@dameng324
Copy link
Owner

No description provided.

Introduced RuntimeProtoParser<T> for dynamic runtime parsing and serialization of protobuf messages. Extended ICollectionWriter and serializer extension methods to support runtime message handling. Added comprehensive tests for runtime parser functionality.
Copilot AI review requested due to automatic review settings January 20, 2026 09:56
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 Runtime Model API support to LightProto, enabling dynamic runtime parser creation without source generation. The implementation introduces a new RuntimeProtoParser<T> class that implements IProtoReader/IProtoWriter interfaces and allows users to register parsers for types at runtime.

Changes:

  • Added RuntimeProtoParser<T> for dynamic runtime parser construction with member registration
  • Extended ICollectionWriter interface with Tag and ItemWireType properties to support runtime scenarios
  • Enhanced constructor resolution in Serializer.Dynamically.cs to handle parsers with various constructor signatures
  • Improved generator diagnostics for CompatibilityLevel and ProtoMap validation with clearer type-specific error messages
  • Added support for Nullable<T> and Lazy<T> in DataFormat and CompatibilityLevel validation

Reviewed changes

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

Show a summary per file
File Description
src/LightProto/RuntimeProtoParser.cs New internal class providing runtime parser implementation with dynamic member registration
src/LightProto/Serializer.Extensions.cs Added non-generic overloads of WriteMessageTo and ParseMessageFrom for runtime object handling
src/LightProto/Serializer.Dynamically.cs Enhanced constructor resolution logic to support parsers with multiple constructor signatures; exposed internal constants for AOT warnings
src/LightProto/Parser/IEnumerableWriter.cs Extended ICollectionWriter interface with internal properties for tag and wire type
src/LightProto.Generator/ProtoContract.cs Refactored validation logic for CompatibilityLevel and DataFormat to use helper methods; changed diagnostic messages to show type names instead of member names
src/LightProto.Generator/LightProtoGeneratorWarning.cs Updated diagnostic messages for CompatibilityLevel and ProtoMap errors to reflect type-based validation
src/LightProto.Generator/Helper.cs Added helper methods for validating CompatibilityLevel support; added Nullable/Lazy type support; refactored support methods
tests/LightProto.Tests/RuntimeParserTests.cs Added comprehensive tests for runtime parser functionality including generic type registration
tests/LightProto.Tests/Parsers/PrimitiveArrayTests.cs Added pragma directives to suppress warnings for intentionally problematic test cases
tests/TestAot/Program.cs Modified AOT test (currently uses protobuf-net API instead of LightProto)
src/LightProto/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Added new extension methods to public API surface
src/LightProto/PublicAPI/net/PublicAPI.Unshipped.txt Added new extension methods to public API surface
docs/Diagnostics.md Updated documentation for CompatibilityLevel diagnostics with clearer explanations

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 96.92308% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.88%. Comparing base (8bfb0b4) to head (5c420cf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/LightProto/Serializer.Extensions.cs 87.09% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #169      +/-   ##
==========================================
- Coverage   98.71%   97.88%   -0.83%     
==========================================
  Files         111      114       +3     
  Lines        2250     2365     +115     
  Branches      250      267      +17     
==========================================
+ Hits         2221     2315      +94     
- Misses         17       30      +13     
- Partials       12       20       +8     

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

Split RuntimeProtoParser<T> into RuntimeProtoReader<T> and RuntimeProtoWriter<T> for clearer separation of concerns and improved extensibility. Updated generator warnings to use type names instead of member names. Adjusted tests and public API to use the new reader and writer classes, and improved test coverage for runtime serialization and deserialization.
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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.

@github-actions

This comment has been minimized.

Diagnostic warnings now include member names for better clarity. Added CalculateMessageSize extension for IProtoWriter and updated related usages. Improved dynamic parser instantiation logic and added a new generic runtime parser test.
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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.

@github-actions

This comment has been minimized.

Added missing spaces in the messageFormat strings of DiagnosticDescriptor instances to improve readability and consistency in warning messages.
@github-actions

This comment has been minimized.

Refactored message parsing logic in Serializer.Extensions for improved code reuse and inlining, and updated dynamic parser instantiation in Serializer.Dynamically. Added new tests for missing fields and enhanced runtime parser coverage, including generic and custom collection scenarios. Also improved method signatures and test clarity in RuntimeParserTests.
@github-actions

This comment has been minimized.

Introduces a new LightProto.InternalTests project for internal and edge-case tests, moving relevant test files from LightProto.Tests. Updates InternalsVisibleTo in LightProto.csproj, adds new test cases, and cleans up duplicated or misplaced tests from the main test suite. Also makes minor improvements to helper methods and updates BenchmarkDotNet version in Benchmark.csproj.
Changed test namespaces from LightProto.Tests to LightProto.InternalTests for internal test files. Added new tests and helper methods to RuntimeParserTests to improve coverage, including tests for serialization/deserialization equivalence and handling of types without suitable constructors.
@github-actions

This comment has been minimized.

@github-actions
Copy link


BenchmarkDotNet v0.15.8, 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 RatioSD Allocated Alloc Ratio
Deserialize_ProtoBuf_net .NET 10.0 .NET 10.0 810.6 μs 7.17 μs 6.70 μs 1.25 0.01 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 10.0 .NET 10.0 683.6 μs 7.87 μs 6.98 μs 1.06 0.01 648.7 KB 1.13
Deserialize_LightProto .NET 10.0 .NET 10.0 646.2 μs 3.88 μs 3.63 μs 1.00 0.01 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 8.0 .NET 8.0 935.6 μs 10.32 μs 9.65 μs 1.36 0.02 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 8.0 .NET 8.0 862.0 μs 6.07 μs 5.38 μs 1.25 0.01 648.7 KB 1.13
Deserialize_LightProto .NET 8.0 .NET 8.0 687.2 μs 5.25 μs 4.91 μs 1.00 0.01 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 9.0 .NET 9.0 867.3 μs 5.70 μs 5.33 μs 1.26 0.02 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 9.0 .NET 9.0 754.8 μs 6.27 μs 5.87 μs 1.10 0.02 648.7 KB 1.13
Deserialize_LightProto .NET 9.0 .NET 9.0 688.3 μs 11.58 μs 10.27 μs 1.00 0.02 574.8 KB 1.00

BenchmarkDotNet v0.15.8, 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 RatioSD Allocated Alloc Ratio
Serialize_ProtoBuf_net .NET 10.0 .NET 10.0 946.2 μs 13.38 μs 12.51 μs 1.28 0.03 526.41 KB 1.03
Serialize_GoogleProtoBuf .NET 10.0 .NET 10.0 828.7 μs 11.46 μs 10.16 μs 1.12 0.03 512.95 KB 1.00
Serialize_LightProto .NET 10.0 .NET 10.0 737.4 μs 14.26 μs 16.98 μs 1.00 0.03 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 8.0 .NET 8.0 1,062.6 μs 20.58 μs 26.03 μs 1.30 0.04 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 8.0 .NET 8.0 842.3 μs 8.12 μs 7.20 μs 1.03 0.02 512.95 KB 1.00
Serialize_LightProto .NET 8.0 .NET 8.0 817.5 μs 13.08 μs 12.24 μs 1.00 0.02 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 9.0 .NET 9.0 1,068.9 μs 21.10 μs 35.83 μs 1.35 0.05 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 9.0 .NET 9.0 856.5 μs 16.11 μs 15.06 μs 1.08 0.02 512.95 KB 1.00
Serialize_LightProto .NET 9.0 .NET 9.0 793.0 μs 13.16 μs 12.31 μs 1.00 0.02 512.92 KB 1.00

@dameng324 dameng324 merged commit 2041909 into main Jan 21, 2026
8 checks passed
@dameng324 dameng324 deleted the runtime-model branch January 21, 2026 07:19
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