Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Aug 27, 2025

Link issues

fixes #6685

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Update ITcpSocketClient AddDataPackageAdapter documentation by replacing obsolete methods with the new generic overload, adding guidance to avoid memory leaks, and introducing a demo for configuring custom data converters.

Documentation:

  • Replace SetDataPackageAdapter usage with AddDataPackageAdapter in samples and include a note to remove callbacks to prevent memory leaks.
  • Add a new demo block showing how to configure custom data converters via ConfigureDataConverters and use the generic AddDataPackageAdapter with MockEntity in OnReceiveAsync.
  • Fix the converter attribute in the sample code from SocketTypeDataConverter to DataTypeConverter.

@Copilot Copilot AI review requested due to automatic review settings August 27, 2025 09:24
@bb-auto bb-auto bot added the documentation Improvements or additions to documentation label Aug 27, 2025
@bb-auto bb-auto bot added this to the 9.9.0 milestone Aug 27, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 27, 2025

Reviewer's Guide

This PR refines the ITcpSocketClient documentation by renaming the converter attribute, introducing a new ConfigureDataConverters/ DataPackageAdapter sample for MockEntity, and updating all sample usages of SetDataPackageAdapter to AddDataPackageAdapter (with memory‐leak notes).

Sequence diagram for AddDataPackageAdapter usage and callback invocation

sequenceDiagram
    actor User
    participant ITcpSocketClient
    participant DataPackageAdapter
    participant MockEntity
    User->ITcpSocketClient: AddDataPackageAdapter(adapter, OnReceiveAsync)
    ITcpSocketClient->DataPackageAdapter: Assign adapter
    ITcpSocketClient->User: OnReceiveAsync(MockEntity)
    User->ITcpSocketClient: (Optionally) Remove callback to prevent memory leak
Loading

Class diagram for updated MockEntity and Data converter configuration

classDiagram
    class MockEntity {
      +byte[]? Header
      +byte[]? Body
    }
    class DataTypeConverter {
      +Type: Type
    }
    class DataPropertyConverterAttribute {
      +Type: Type
      +Offset: int
      +Length: int
    }
    MockEntity <|-- DataTypeConverter
    MockEntity "1" o-- "*" DataPropertyConverterAttribute: property converters
Loading

File-Level Changes

Change Details Files
Renamed the data converter attribute and added a full MockEntity configuration/demo
  • Replaced [SocketTypeDataConverter] with [DataTypeConverter]
  • Added ConfigureDataConverters sample showing type- and property-level converters
  • Added DataPackageAdapter + AddDataPackageAdapter usage in OnReceiveAsync
src/BootstrapBlazor.Server/Components/Samples/Sockets/DataEntities.razor
Replaced SetDataPackageAdapter with AddDataPackageAdapter and added leak-prevention note in Adapters sample
  • Updated inline code examples to use AddDataPackageAdapter
  • Added warning to remove callbacks when client lives beyond page
src/BootstrapBlazor.Server/Components/Samples/Sockets/Adapters.razor
Applied same AddDataPackageAdapter replacement with leak warning in SocketFactories sample
  • Replaced SetDataPackageAdapter call with AddDataPackageAdapter
  • Inserted comment on RemoveDataPackageAdapter to prevent memory leaks
src/BootstrapBlazor.Server/Components/Samples/SocketFactories.razor
Updated commented sample in code-behind to reflect AddDataPackageAdapter
  • Changed commented SetDataPackageAdapter to AddDataPackageAdapter
src/BootstrapBlazor.Server/Components/Samples/Sockets/Adapters.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6685 Update the documentation to describe the usage of AddDataPackageAdapter in ITcpSocketClient.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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 PR updates documentation for the ITcpSocketClient interface, specifically changing method references from SetDataPackageAdapter to AddDataPackageAdapter and adds new configuration examples. The changes include localized content updates, code sample corrections, and package version updates.

  • Updated method references from SetDataPackageAdapter to AddDataPackageAdapter across documentation
  • Added new configuration examples for data type converters using ConfigureDataConverters
  • Updated package references to newer versions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/BootstrapBlazor.Server/Locales/zh-CN.json Added Chinese localization for new configuration section
src/BootstrapBlazor.Server/Locales/en-US.json Added English localization for new configuration section
src/BootstrapBlazor.Server/Components/Samples/Sockets/DataEntities.razor Corrected attribute name and added configuration example
src/BootstrapBlazor.Server/Components/Samples/Sockets/Adapters.razor.cs Updated method reference in comments
src/BootstrapBlazor.Server/Components/Samples/Sockets/Adapters.razor Updated method reference and added memory leak warning
src/BootstrapBlazor.Server/Components/Samples/SocketFactories.razor Updated method reference and added memory leak prevention comment
src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj Updated package versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

<Pre>// 实战中可以使用 ITcpSocketClient 扩展方法 SetDataPackageAdapter 简化代码
_client.SetDataPackageAdapter(_dataAdapter, UpdateReceiveLog);</Pre>
<Pre>// 实战中可以使用 ITcpSocketClient 扩展方法 AddDataPackageAdapter 简化代码
// 如果 _client 实例在当前页面不销毁时,切记使用 AddDataPackageAdapter 移除当前页面加载的 UpdateReceiveLog 回调方法避免内存泄露
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions using 'AddDataPackageAdapter' to remove a callback method, but 'AddDataPackageAdapter' is typically used to add adapters. The comment should reference the correct method name for removing adapters, likely 'RemoveDataPackageAdapter'.

Suggested change
// 如果 _client 实例在当前页面不销毁时,切记使用 AddDataPackageAdapter 移除当前页面加载的 UpdateReceiveLog 回调方法避免内存泄露
// 如果 _client 实例在当前页面不销毁时,切记使用 RemoveDataPackageAdapter 移除当前页面加载的 UpdateReceiveLog 回调方法避免内存泄露

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang merged commit 69339a5 into main Aug 27, 2025
4 checks passed
@ArgoZhang ArgoZhang deleted the doc-socket branch August 27, 2025 09:26
@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (481b744) to head (540749e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6686   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          739       739           
  Lines        31698     31698           
  Branches      4462      4462           
=========================================
  Hits         31698     31698           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(ITcpSocketClient): update AddDataPackageAdapter documentation

1 participant