feat(DataConverter): add logger for Debugger attached#568
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis 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 loggingsequenceDiagram
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
Class diagram for updated DataConverter.Parse loggingclassDiagram
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
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.
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.
There was a problem hiding this comment.
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.IsAttachedso 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Link issues
fixes #567
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
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:
Bug Fixes:
Enhancements: