Update UserAgent to pipe-delimited format#3826
Conversation
There was a problem hiding this comment.
Pull request overview
This PR transitions the UserAgent feature from a JSON-based format to a pipe-delimited format for the TDS LOGIN7 USERAGENT Feature Extension. The change simplifies the implementation by eliminating JSON serialization overhead and aligns with the latest specification.
Key Changes:
- Replaced JSON-serialized UserAgent with a pipe-delimited string format (
1|MS-MDS|{version}|{OS}|{arch}|{OS info}|{runtime info}) - Removed version byte from the feature extension payload (previously 1 byte for version + JSON, now just the UCS-2 encoded pipe-delimited string)
- Changed encoding from UTF-8 to UCS-2 (little-endian Unicode)
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs |
New implementation of UserAgent class with pipe-delimited format, replacing the previous JSON-based implementation |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent/UserAgentInfo.cs |
Removed - old JSON-based UserAgent implementation |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent/UserAgentInfoDto.cs |
Removed - DTO for JSON serialization, no longer needed |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs |
Updated to use new pipe-delimited format; removed version byte from payload; updated parameter types from byte[] to ReadOnlyMemory<byte> |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs |
Removed constants for version byte and SQL_PROVIDER_NAME that are no longer used |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs |
Replaced TdsEnums.SQL_PROVIDER_NAME with direct reference to DbConnectionStringDefaults.ApplicationName |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlError.cs |
Replaced TdsEnums.SQL_PROVIDER_NAME with direct reference to DbConnectionStringDefaults.ApplicationName |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs |
Updated documentation comment for EnableUserAgent property |
src/Microsoft.Data.SqlClient/tests/UnitTests/UserAgentTests.cs |
New comprehensive unit tests for the pipe-delimited UserAgent implementation |
src/Microsoft.Data.SqlClient/tests/UnitTests/UserAgentInfoTests.cs |
Removed - tests for old JSON-based implementation |
src/Microsoft.Data.SqlClient/tests/UnitTests/TdsParserInternalsTest.cs |
Updated tests to expect new pipe-delimited format without version byte |
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs |
Updated integration test to validate new UserAgent format |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/UdtSerialization/NativeSerializationTest.cs |
Added DisableDiscoveryEnumeration to improve test performance (unrelated optimization) |
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs |
Added comment clarification (cosmetic change) |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj |
Updated project file to reference new UserAgent.cs and remove old files |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj |
Updated project file to reference new UserAgent.cs and remove old files |
spec/user-agent-v1.jsonc |
Removed - JSON schema specification no longer applicable |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
Outdated
Show resolved
Hide resolved
paulmedynski
left a comment
There was a problem hiding this comment.
Commentary for reviewers, and things for me to fix.
...lClient/tests/UnitTests/Microsoft/Data/SqlClient/UdtSerialization/NativeSerializationTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs
Outdated
Show resolved
Hide resolved
1dfbd58 to
6cc390d
Compare
|
Is this feature available in any released version of the SQL engine? |
AFAIK the server side is being implemented for Azure SQL. I don't believe there are plans to include it with SQL Server box editions. |
37d0bbd to
4e2d023
Compare
4e2d023 to
e67cbdf
Compare
|
I will wait for #3772 to merge before I merge this PR. |
…Agent. - Reverted commit e0fa87b. - Removed the JSON-based user agent classes. - Updated UserAgent to produce the proper pipe-delimited format. - Updated TDS emission to remove UserAgent version byte. - Swapped the Architecture and OS Type fields.
fc9e6a6 to
db6cc4d
Compare
samsharma2700
left a comment
There was a problem hiding this comment.
Minor change suggestion, everything else looks great!
Description
This PR updates the UserAgent feature (once again) to employ the latest pipe-delimited format. The previous JSON format code has been removed.
The latest spec is here: SQL Drivers User Aget V1
Testing