Skip to content

feat(DataConverter): add logger for Debugger attached#568

Merged
ArgoZhang merged 4 commits intomasterfrom
feat-socket
Sep 2, 2025
Merged

feat(DataConverter): add logger for Debugger attached#568
ArgoZhang merged 4 commits intomasterfrom
feat-socket

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Sep 2, 2025

Link issues

fixes #567

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 conditional debug logging of raw socket data and enrich parse error messages in DataConverter.Parse when a debugger is attached

New Features:

  • Log raw byte data when a debugger is attached during data conversion

Bug Fixes:

Enhancements:

  • Include offset, length, property name, and type in parse failure log messages

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

sourcery-ai Bot commented Sep 2, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR enhances the DataConverter.Parse method by detecting when a debugger is attached to emit raw data debug logs and enriches conversion failure messages with detailed context (offset, length, property name and type).

Sequence diagram for DataConverter.Parse with Debugger attached logging

sequenceDiagram
    participant DataConverter
    participant Debugger
    participant SocketLogging
    participant Entity
    DataConverter->>Debugger: Check IsAttached
    alt Debugger is attached
        DataConverter->>SocketLogging: LogDebug(raw data)
    end
    DataConverter->>Entity: Get writable properties
    loop For each property
        DataConverter->>Entity: Get property attribute
        alt Conversion fails
            DataConverter->>SocketLogging: LogInformation(failure details)
        end
    end
Loading

Class diagram for updated DataConverter.Parse logging

classDiagram
    class DataConverter {
        <<abstract>>
        +Parse(data: ReadOnlyMemory<byte>, entity: TEntity): bool
    }
    class SocketLogging {
        +LogDebug(message: string)
        +LogInformation(message: string)
    }
    DataConverter --> SocketLogging : uses
    DataConverter ..> System.Diagnostics.Debugger : checks IsAttached
Loading

File-Level Changes

Change Details Files
Add raw data logging when a debugger is attached
  • Import System.Diagnostics namespace
  • Check Debugger.IsAttached before logging
  • Log raw incoming data as debug output
src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverter.cs
Enhance conversion failure log details
  • Include property offset and length in LogInformation
  • Append failing property name and type to error messages
src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverter.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#567 Add a logger statement that logs when the Debugger is attached in the DataConverter class.

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
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 debug logging functionality to the DataConverter class to help with troubleshooting socket data parsing issues. When a debugger is attached, it now logs the raw byte data being processed.

  • Adds conditional debug logging to output raw byte data when debugger is attached
  • Improves error message formatting to include more detailed property information
  • Updates version from 9.0.11 to 9.0.14

Reviewed Changes

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

File Description
DataConverter.cs Adds debug logging for raw data and improves error message detail
BootstrapBlazor.Socket.csproj Version bump to 9.0.14

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

Comment thread src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverter.cs Outdated
Comment thread src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverter.cs Outdated
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 - here's some feedback:

  • Remove the redundant var debug = System.Diagnostics.Debugger.IsAttached; local since it’s declared but never used.
  • Consider driving debug output via your logging framework’s debug level rather than Debugger.IsAttached so it can be toggled without attaching a debugger.
  • Using BitConverter.ToString(data.ToArray()) allocates a new array and string each time—consider logging a hex span or truncating large payloads to avoid performance issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the redundant `var debug = System.Diagnostics.Debugger.IsAttached;` local since it’s declared but never used.
- Consider driving debug output via your logging framework’s debug level rather than `Debugger.IsAttached` so it can be toggled without attaching a debugger.
- Using `BitConverter.ToString(data.ToArray())` allocates a new array and string each time—consider logging a hex span or truncating large payloads to avoid performance issues.

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 5d5997b into master Sep 2, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the feat-socket branch September 2, 2025 03:15
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(DataConverter): add logger for Debugger attached

2 participants