Skip to content

feat(Socket): HexConvert method support upper and lower case #546

Merged
ArgoZhang merged 3 commits intomasterfrom
feat-socket
Aug 27, 2025
Merged

feat(Socket): HexConvert method support upper and lower case #546
ArgoZhang merged 3 commits intomasterfrom
feat-socket

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Aug 27, 2025

Link issues

fixes #545

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

Enable optional uppercase or lowercase output in HexConverter.ToString, streamline its implementation, and clean up minor code issues

Enhancements:

  • Add an 'upper' parameter to HexConverter.ToString to choose between uppercase and lowercase hex output
  • Replace the StringBuilder loop with a string.Join and LINQ-based implementation in HexConverter
  • Remove the unused System.Text using directive from HexConverter
  • Apply minor whitespace formatting cleanup in DataPropertyExtensions

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

sourcery-ai Bot commented Aug 27, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a boolean flag to HexConverter.ToString to toggle uppercase/lowercase output and simplifies its implementation by replacing the StringBuilder loop with a LINQ-based string.Join approach; also removes an unused using and applies a minor formatting tweak in DataPropertyExtensions.

Class diagram for updated HexConverter.ToString method

classDiagram
    class HexConverter {
        +static string ToString(byte[]? bytes, string? separator = "-", bool upper = true)
    }
Loading

Class diagram for DataPropertyExtensions formatting change

classDiagram
    class DataPropertyExtensions {
        static object? GetConverter(Type converterType, Attribute attribute)
    }
Loading

File-Level Changes

Change Details Files
Introduce 'upper' flag and refactor HexConverter.ToString
  • Add bool upper parameter to method signature
  • Replace StringBuilder loop with bytes.Select and string.Join conditional formatting
  • Remove unused System.Text using directive
src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs
Apply minor formatting fix in DataPropertyExtensions
  • Adjust spacing around if statement for consistency
src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#545 Add support for both upper and lower case output in the HexConvert method.

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

@ArgoZhang ArgoZhang merged commit 6c2054e into master Aug 27, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the feat-socket branch August 27, 2025 03:24
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 enhances the HexConverter.ToString method to support both uppercase and lowercase hexadecimal output formatting. The change adds a new upper parameter that controls the case of the hexadecimal representation while maintaining backward compatibility with a default value of true.

  • Adds an optional upper boolean parameter to control hex case formatting
  • Simplifies the implementation using LINQ and string.Join
  • Removes the StringBuilder approach in favor of a more concise implementation
Comments suppressed due to low confidence (1)

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

/// </summary>
/// <param name="bytes">The byte array to convert.</param>
/// <param name="separator"></param>
/// <param name="upper"></param>
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 XML documentation for the 'upper' parameter is incomplete. It should describe what the parameter does, e.g., '/// True for uppercase hexadecimal letters (A-F), false for lowercase (a-f).'

Suggested change
/// <param name="upper"></param>
/// <param name="upper">True for uppercase hexadecimal letters (A-F), false for lowercase (a-f).</param>

Copilot uses AI. Check for mistakes.
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!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs:20` </location>
<code_context>
+    /// <param name="upper"></param>
     /// <returns>A string containing the hexadecimal representation of the byte array.</returns>
-    public static string ToString(byte[]? bytes, string? separator = "-")
+    public static string ToString(byte[]? bytes, string? separator = "-", bool upper = true)
     {
         if (bytes == null || bytes.Length == 0)
</code_context>

<issue_to_address>
Consider documenting the new 'upper' parameter in the XML summary for clarity.

Updating the XML summary to explain how 'upper' affects the output will improve maintainability.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    /// <param name="bytes">The byte array to convert.</param>
    /// <param name="separator"></param>
    /// <param name="upper"></param>
    /// <returns>A string containing the hexadecimal representation of the byte array.</returns>
=======
    /// <param name="bytes">The byte array to convert.</param>
    /// <param name="separator">The separator to use between hexadecimal byte values.</param>
    /// <param name="upper">If true, returns the hexadecimal string in uppercase; if false, returns it in lowercase.</param>
    /// <returns>A string containing the hexadecimal representation of the byte array.</returns>
>>>>>>> REPLACE

</suggested_fix>

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.

Comment on lines 16 to 19
/// <param name="bytes">The byte array to convert.</param>
/// <param name="separator"></param>
/// <param name="upper"></param>
/// <returns>A string containing the hexadecimal representation of the byte array.</returns>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider documenting the new 'upper' parameter in the XML summary for clarity.

Updating the XML summary to explain how 'upper' affects the output will improve maintainability.

Suggested change
/// <param name="bytes">The byte array to convert.</param>
/// <param name="separator"></param>
/// <param name="upper"></param>
/// <returns>A string containing the hexadecimal representation of the byte array.</returns>
/// <param name="bytes">The byte array to convert.</param>
/// <param name="separator">The separator to use between hexadecimal byte values.</param>
/// <param name="upper">If true, returns the hexadecimal string in uppercase; if false, returns it in lowercase.</param>
/// <returns>A string containing the hexadecimal representation of the byte array.</returns>

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): HexConvert method support upper and lower case

2 participants