Skip to content

feat(Socket): add DataByteConverter#562

Merged
ArgoZhang merged 9 commits intomasterfrom
refactor-socket
Aug 31, 2025
Merged

feat(Socket): add DataByteConverter#562
ArgoZhang merged 9 commits intomasterfrom
refactor-socket

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Aug 31, 2025

Link issues

fixes #561

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

Introduce support for converting single-byte data by adding DataByteConverter and updating property conversion logic, while cleaning up related code and improving error logging.

New Features:

  • Add DataByteConverter for single-byte property conversion
  • Extend DataPropertyExtensions to use DataByteConverter for byte types

Enhancements:

  • Improve error logging in DataConverter.TryConvertTo to include the method name
  • Remove unused variables and streamline the Parse method in DataConverter

Tests:

  • Remove unused logging import in TcpSocketFactoryTest

Copilot AI review requested due to automatic review settings August 31, 2025 01:06
@bb-auto bb-auto Bot added the enhancement New feature or request label Aug 31, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Aug 31, 2025
Copy link
Copy Markdown

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 adds a new DataByteConverter class to handle conversion of socket data to single byte values, addressing issue #561. The implementation provides support for converting ReadOnlyMemory<byte> data to individual byte values in the Socket data property conversion system.

  • Adds DataByteConverter class for single byte data conversion
  • Integrates the new converter into the property extension system
  • Removes unused code and cleans up formatting in existing files

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DataByteConverter.cs New converter class for single byte data conversion
DataPropertyExtensions.cs Adds support for byte type in converter selection logic
DataConverter.cs Code cleanup including unused variable removal and formatting improvements
TcpSocketFactoryTest.cs Removes unused import statement
BootstrapBlazor.Socket.csproj Version bump from 9.0.8 to 9.0.10

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

Comment thread src/extensions/BootstrapBlazor.Socket/PropertyConverter/DataByteConverter.cs Outdated
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 31, 2025

Reviewer's Guide

This PR introduces a dedicated DataByteConverter to handle single-byte socket data, integrates it into the property conversion pipeline, and refactors the existing DataConverter implementation for clearer logging and cleaner code while removing an unused test import.

Class diagram for DataByteConverter integration

classDiagram
    class IDataPropertyConverter {
        <<interface>>
        +Convert(ReadOnlyMemory<byte> data) object?
    }
    class DataByteConverter {
        +Convert(ReadOnlyMemory<byte> data) object?
    }
    IDataPropertyConverter <|.. DataByteConverter
    class DataByteArrayConverter {
        +Convert(ReadOnlyMemory<byte> data) object?
    }
    IDataPropertyConverter <|.. DataByteArrayConverter
Loading

Class diagram for DataPropertyExtensions converter selection

classDiagram
    class DataPropertyExtensions {
        +GetConverter(attribute) : IDataPropertyConverter
    }
    class DataByteConverter
    class DataByteArrayConverter
    DataPropertyExtensions --> DataByteConverter : if type == byte
    DataPropertyExtensions --> DataByteArrayConverter : if type == byte[]
Loading

File-Level Changes

Change Details Files
Add DataByteConverter for byte type conversion
  • Created DataByteConverter implementing IDataPropertyConverter returning the first byte of data
  • Registered DataByteConverter in DataPropertyExtensions when attribute.Type is byte
src/extensions/BootstrapBlazor.Socket/PropertyConverter/DataByteConverter.cs
src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs
Enhance logging and clean up in DataConverter
  • Replaced hardcoded method name with nameof(TryConvertTo) in error logging
  • Removed unused unuseProperties list and trimmed extra blank lines
src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverter.cs
Remove unused using directive in test
  • Deleted unused BootstrapBlazor.Socket.Logging import from TcpSocketFactoryTest
test/UnitTestTcpSocket/TcpSocketFactoryTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#561 Add a DataByteConverter class to the codebase for Socket data conversion.
#561 Integrate DataByteConverter into the Socket data conversion logic so that it is used when appropriate (e.g., for byte properties).

Possibly linked issues

  • feat(Socket): add DataByteConverter #561: The PR adds a DataByteConverter to handle byte data type conversions, which directly addresses the issue of adding data type checks to prevent assignment exceptions for byte types.

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
Copy Markdown

@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 a439342 into master Aug 31, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the refactor-socket branch August 31, 2025 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Socket): add DataByteConverter

2 participants