Skip to content

Conversation

samsharma2700
Copy link
Contributor

Description

Part 2 of UserAgent work. Previous PR: #3451

Testing

Builds are running and added unit tests to verify changes.

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 20:41
@samsharma2700 samsharma2700 requested a review from a team as a code owner July 17, 2025 20:41
Copy link
Contributor

@Copilot 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 implements the JSON payload functionality for the User Agent feature extension in Microsoft.Data.SqlClient, adding the core infrastructure for generating and managing user agent information that will be sent to SQL Server during connection establishment.

  • Implements UserAgentInfo class with OS detection, architecture detection, and runtime information gathering
  • Adds UserAgentInfoDto as a serializable data transfer object with size constraints and field-dropping logic
  • Includes comprehensive unit tests covering field truncation, payload sizing, and JSON serialization

Reviewed Changes

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

Show a summary per file
File Description
UserAgentInfo.cs (netfx/netcore) Core implementation with OS/runtime detection and JSON payload generation with size constraints
UserAgentInfoDto.cs (netfx/netcore) Data transfer object for JSON serialization with property name constants
UserAgentInfoTests.cs Unit tests covering truncation logic, payload sizing, and JSON contract validation
Microsoft.Data.SqlClient.csproj (netfx/netcore) Project file updates to include the new UserAgent classes
Microsoft.Data.SqlClient.UnitTests.csproj Test project configuration with empty folder reference
Comments suppressed due to low confidence (2)

@roji
Copy link
Member

roji commented Jul 17, 2025

@samsharma2700 @cheenamalhotra great to see this work happening. I've taken a look at the spec doc linked above, and could you clarify how we'd go about injecting EF information into the user agent? We'd need to identify EF Core (as opposed to direct users of SqlClient), it's version, etc.

@paulmedynski
Copy link
Contributor

Hi @roji - There is a V2 of the design that adds a public API for middleware like EF to pass version information, but we need to go through a security and privacy review before we can implement it. This V1 phase only includes values we can pull from the runtime that don't have any such concerns.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Need to move the UserAgent files into the src/ project and avoid duplicating them. I'll complete my review after the move.

@roji
Copy link
Member

roji commented Jul 18, 2025

@paulmedynski ok - can you clarify what's planned for the 6.1.0 (v1, v2?)

@paulmedynski paulmedynski added this to the 7.0-preview1 milestone Jul 18, 2025
@paulmedynski
Copy link
Contributor

The V1 work will arrive in 7.0.0. The V2 work to support EF and other middleware may also make it into that timeframe, but depends on which reviews we need and how long they take. There is also ongoing SQL Server support that we need to align with to make any of this driver side work useful.

@samsharma2700 will be completing the V1 work over several PRs. We have (and will) put them into the 7.0.0-preview1 milestone.

Copy link

codecov bot commented Jul 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.82%. Comparing base (42146a3) to head (8ad6f59).
⚠️ Report is 36 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3489       +/-   ##
===========================================
+ Coverage   68.85%   90.82%   +21.96%     
===========================================
  Files         277        6      -271     
  Lines       62237      316    -61921     
===========================================
- Hits        42854      287    -42567     
+ Misses      19383       29    -19354     
Flag Coverage Δ
addons 90.82% <ø> (ø)
netcore ?
netfx ?

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.

@roji
Copy link
Member

roji commented Jul 19, 2025

@paulmedynski thanks for the clarifications!

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

You're on the right track here. We can discuss my comments and suggestions.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Very close now; just a few more comments.

Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

😬 I'm gonna force braces for if statements if it's the last thing I do

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Getting closer!

paulmedynski
paulmedynski previously approved these changes Aug 21, 2025
benrr101
benrr101 previously approved these changes Aug 22, 2025
Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants