-
-
Notifications
You must be signed in to change notification settings - Fork 25
Add protobuf serialization infrastructure #493
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
base: v5.0
Are you sure you want to change the base?
Conversation
- Add protobuf-net package for binary serialization support - Add ProtobufSerializationBase.cs with base records for serialization - Add IProtobufSerializable interface for type contracts - Add ProtobufSerializableAttribute and SerializedMethodAttribute - Add JsSyncManager stub for JS interop with protobuf support - Add ProtobufSourceGenerator skeleton for future serialization code generation - Update ESBuildGenerator to use new shared project structure - Add SourceGenerator.Shared project with ProcessHelper and extension methods - Update Directory.Build.props with CoreProjectPath for source generators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude finished @TimPurdum's task —— View job PR Review: Add protobuf serialization infrastructureTodo List:
Review SummaryThis PR introduces the foundational infrastructure for protobuf-based binary serialization in GeoBlazor Core. While the implementation is largely skeletal (as intended for this incremental approach), there are several important code quality and design issues that should be addressed. Critical Issues1. Missing Assembly Reference (GeoBlazorMetaData.cs:11)Assembly proAssembly = Assembly.Load("dymaptic.GeoBlazor.Pro");Problem: Missing Fix: Add the missing using statement at the top of the file. 2. Unsafe Null Handling (ProtobufDefinitionsGenerator.cs:56)return ProtoDefinitions!; // Null-forgiving operator without validationProblem: Using null-forgiving operator without ensuring the dictionary is actually populated. If Recommendation: Add proper null checking: return ProtoDefinitions ?? new Dictionary<string, ProtoMessageDefinition>();3. PowerShell Script Security Concerns (ProcessHelper.cs:16-17)string shellArguments = $"-NoProfile -ExecutionPolicy ByPass -File \"{
Path.Combine(workingDirectory, powershellScriptName)}\" {arguments}";Security Risk: Using Recommendation: Consider using 4. Inconsistent Error Handling (ProcessHelper.cs:87-92)if (exitCode != 0)
{
logBuilder.AppendLine(outputBuilder.ToString()); // Duplicate logging
throw new Exception($"{processName}: Error executing command '{shellArguments}' for process {processId}. Exit code: {exitCode}");
}Problem: The output is logged twice (line 75 and 89), and using generic Fix: Remove duplicate logging and use more specific exceptions like Code Quality Issues5. Incomplete Implementation PatternMultiple classes have empty or placeholder implementations:
Recommendation: Consider adding TODO comments or XML documentation explaining when these will be implemented. 6. String Concatenation Performance (ProtobufDefinitionsGenerator.cs:32-35)string encoded = typescriptContent
.Replace("\"", "\\\"")
.Replace("\r\n", "\\r\\n")
.Replace("\n", "\\n");Issue: Multiple string replacements create intermediate strings. Optimization: Use 7. Hardcoded Magic Numbers
Recommendation: Use const fields or document why 1000 is chosen. Architecture and Design Concerns8. Source Generator ComplexityThe
Recommendation: Consider splitting into separate responsibilities for better maintainability. 9. Global State Managementpublic static Dictionary<string, ProtoMessageDefinition>? ProtoDefinitions;Issue: Mutable global state in source generators can lead to inconsistent behavior across compilation runs. Recommendation: Consider passing state through the generator pipeline instead of using static fields. 10. Exception Swallowing (GeoBlazorMetaData.cs:15-18)catch
{
// GeoBlazor.Pro not available
}Problem: Catching all exceptions without logging specific failure reasons. Fix: At minimum catch specific exceptions and consider logging the attempt. Performance Considerations11. Reflection Performance (GeoBlazorMetaData.cs:7)GeoblazorTypes = typeof(GeoBlazorMetaData).Assembly.GetTypes();Issue: Recommendation: Consider lazy initialization or caching strategies. 12. LINQ Performance in Generators (ProtobufDefinitionsGenerator.cs:105-106)Multiple LINQ operations in hot paths within source generators can impact compilation performance. Recommendation: Consider more efficient enumeration patterns where possible. Documentation and Testing13. Missing XML DocumentationSeveral public APIs lack proper documentation:
14. No Test CoverageThe PR adds significant infrastructure but no corresponding unit tests for:
Positive Aspects✅ Good separation of concerns with the shared source generator project Recommendations for Next Steps
The overall architecture looks sound for the intended incremental approach, but the implementation needs refinement before adding the full protobuf functionality in subsequent PRs. |
- Add TODO comments to placeholder implementations (SerializationExtensions, JsSyncManager, ProtobufSourceGenerator) documenting future work - Document ProtoMember(1000) magic number - reserved for base class properties to avoid conflicts with derived class tags (1-999) - Improve GeoBlazorMetaData exception handling - catch FileNotFoundException specifically instead of bare catch - Add XML documentation to GeoBlazorMetaData class and properties - Fix duplicate logging bug in ProcessHelper - output was being logged in ExitedCommandEvent then cleared, making error diagnostics empty 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude finished @TimPurdum's task —— View job PR Review: Add protobuf serialization infrastructureTodo List:
Review of Changes Since Previous Claude ReviewThe author addressed many of the issues from the previous review in commit ✅ Issues Addressed
❌ Critical Issues Still Remaining1. COMPILATION FAILURE - Missing Using Statement (
|
|
The comment about missing usings is incorrect, Claude is missing the GlobalUsings.cs file consistently. |
…into feature/protobuf-serialization
Summary
This PR introduces the foundational infrastructure for protobuf-based binary serialization in GeoBlazor Core. This is the first in a series of PRs to incrementally merge changes from the
feature/478-multipart-operatorbranch.What's Included
MapComponentSerializationRecordandMapComponentCollectionSerializationRecordprovide the foundation for all protobuf serialization recordsProtobufSerializableAttributeandSerializedMethodAttributefor marking types and methods for serializationProcessHelperfor PowerShell script executionDirectory.Build.propsnow includesCoreProjectPathfor source generatorsWhy Protobuf Serialization?
Binary serialization via protobuf-net offers significant performance improvements over JSON for Blazor Server scenarios:
Relationship to Larger Changes
This PR is part of a planned series to merge the
feature/478-multipart-operatorbranch incrementally. The full change set includes:By merging these changes incrementally, we can:
Test Plan
🤖 Generated with Claude Code