-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(SocketDataConveter): remove abstract keyword #6447
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
Reviewer's GuideThis PR replaces the abstract SocketDataConverterBase with a concrete generic SocketDataConverter (providing a default TryConvertTo and CreateEntity implementation), introduces a DataPackageAdapter abstraction in client samples to replace direct SetDataHandler usage, updates tests and sample components to reference the new converter and adapter types, and applies several minor C# syntax and style cleanups. Class diagram for SocketDataConverter replacing SocketDataConverterBaseclassDiagram
class ISocketDataConverter~TEntity~ {
<<interface>>
+bool TryConvertTo(ReadOnlyMemory<byte> data, out TEntity? entity)
}
class SocketDataConverter~TEntity~ {
+bool TryConvertTo(ReadOnlyMemory<byte> data, out TEntity? entity)
+TEntity CreateEntity()
+bool Parse(ReadOnlyMemory<byte> data, TEntity entity)
}
ISocketDataConverter~TEntity~ <|.. SocketDataConverter~TEntity~
Class diagram for DataPackageAdapter usage in client samplesclassDiagram
class DataPackageAdapter {
+FixLengthDataPackageHandler DataPackageHandler
+event ReceivedCallBack(ReadOnlyMemory<byte> data)
}
class FixLengthDataPackageHandler {
+int Length
}
DataPackageAdapter o-- FixLengthDataPackageHandler : uses
Class diagram for SocketClientOptions minor property updateclassDiagram
class SocketClientOptions {
+IPEndPoint LocalEndPoint
+bool EnableLog
+bool IsAutoReconnect
}
class IPEndPoint
SocketClientOptions o-- IPEndPoint : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Services/TcpSocket/DataConverter/SocketDataConverterBase.cs:34` </location>
<code_context>
+ /// 创建实体实例方法
+ /// </summary>
+ /// <returns></returns>
+ protected virtual TEntity CreateEntity() => Activator.CreateInstance<TEntity>();
/// <summary>
</code_context>
<issue_to_address>
Using Activator.CreateInstance may throw if TEntity lacks a parameterless constructor.
Document the requirement for a public parameterless constructor or handle instantiation for types that lack one.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/BootstrapBlazor/Services/TcpSocket/DataConverter/SocketDataConverterBase.cs
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6447 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 748 748
Lines 32259 32266 +7
Branches 4560 4561 +1
=========================================
+ Hits 32259 32266 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6446
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Remove the abstract socket data converter base class in favor of a concrete generic SocketDataConverter, update adapter and sample code to use the new converter, and enhance examples and tests for attribute-driven data adaptation.
Bug Fixes:
Enhancements:
Documentation:
Tests: