-
Notifications
You must be signed in to change notification settings - Fork 317
Update UserAgent to pipe-delimited format #3826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…Agent. - Removed the JSON-based user agent classes.
- Fixed xUnit console warnings for unrelated tests.
There was a problem hiding this 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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commentary for reviewers, and things for me to fix.
| // internal tdsparser constants | ||
|
|
||
|
|
||
| public const string SQL_PROVIDER_NAME = DbConnectionStringDefaults.ApplicationName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary level of indirection here, so removing this in favour of ApplicationName.
| [MemberData(nameof(SerializedNonNullPrimitiveTypeValues))] | ||
| [MemberData( | ||
| nameof(SerializedNonNullPrimitiveTypeValues), | ||
| DisableDiscoveryEnumeration = true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change to suppress xUnit warnings.
| int expectedDataLen = 1 + payload.Length; | ||
| Assert.Equal(expectedDataLen, dataLenFromStream); | ||
|
|
||
| Assert.Equal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pipe-delimited format doesn't include a version byte. There is a version field embedded in the pipe-delimeted payload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
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