-
Notifications
You must be signed in to change notification settings - Fork 2
Add Runtime Model API Support #169
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
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.
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 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
ICollectionWriterinterface withTagandItemWireTypeproperties to support runtime scenarios - Enhanced constructor resolution in
Serializer.Dynamically.csto 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>andLazy<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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
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
Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.
This comment has been minimized.
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.
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
Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.
This comment has been minimized.
This comment has been minimized.
Added missing spaces in the messageFormat strings of DiagnosticDescriptor instances to improve readability and consistency in warning messages.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
|
No description provided.