Skip to content

Enable User Agent feature extension#4124

Open
cheenamalhotra wants to merge 2 commits intomainfrom
dev/cheena/enableuseragent
Open

Enable User Agent feature extension#4124
cheenamalhotra wants to merge 2 commits intomainfrom
dev/cheena/enableuseragent

Conversation

@cheenamalhotra
Copy link
Copy Markdown
Member

Removes app context switch no longer needed - feature is to be always-enabled.

@cheenamalhotra cheenamalhotra requested a review from a team as a code owner April 1, 2026 06:18
Copilot AI review requested due to automatic review settings April 1, 2026 06:18
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Apr 1, 2026
@cheenamalhotra cheenamalhotra added this to the 7.1.0-preview1 milestone Apr 1, 2026
@cheenamalhotra cheenamalhotra added the Hotfix Candidate 🚑 Issues/PRs that are candidate for backporting to earlier supported versions. label Apr 1, 2026
@cheenamalhotra cheenamalhotra moved this from To triage to In review in SqlClient Board Apr 1, 2026
Copy link
Copy Markdown
Contributor

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 removes the EnableUserAgent AppContext switch and makes the UserAgent TDS feature extension always included when feature extensions are requested, aligning the driver behavior with always-on UserAgent support.

Changes:

  • Remove LocalAppContextSwitches.EnableUserAgent and related test helper plumbing.
  • Always write the UserAgent feature extension request in TdsParser when requestedFeatures includes UserAgent.
  • Update simulated server unit tests to stop toggling the removed switch.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs Removes per-test switch toggling for UserAgent feature extension.
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/LocalAppContextSwitchesTest.cs Drops the default-value assertion for the removed switch.
src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs Removes reflection-based support for capturing/restoring the removed switch.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs Removes the AppContext gate so UserAgent request is written whenever requested.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs Deletes the EnableUserAgent switch definition, cache field, and accessor.

Comment on lines 908 to 913
[Fact]
public void TestConnWithoutUserAgentFeatureExtension()
{
// Disable the client-side UserAgent field entirely
using LocalAppContextSwitchesHelper switchesHelper = new();
switchesHelper.EnableUserAgent = false;

using var server = new TdsServer();
server.Start();

Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

TestConnWithoutUserAgentFeatureExtension now runs with UserAgent implicitly requested (see SqlConnectionInternal sets requestedFeatures |= ...UserAgent), so this test's purpose/expectations are no longer valid and it will fail once the client always sends the UserAgent feature extension. Consider removing this test or rewriting it to validate behavior when the server does not ACK/support UserAgent (connection still succeeds, and/or correct ordering/payload).

Copilot uses AI. Check for mistakes.
@cheenamalhotra cheenamalhotra added Hotfix 7.0.1 When this PR merges, automatically open a PR to cherry-pick to the 7.0.1 branch and removed Hotfix Candidate 🚑 Issues/PRs that are candidate for backporting to earlier supported versions. labels Apr 1, 2026
@ErikEJ
Copy link
Copy Markdown
Contributor

ErikEJ commented Apr 1, 2026

Is this info avaliable on the Azure SQL side and if so, how?

@github-project-automation github-project-automation bot moved this from In review to In progress in SqlClient Board Apr 1, 2026
@paulmedynski paulmedynski self-assigned this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hotfix 7.0.1 When this PR merges, automatically open a PR to cherry-pick to the 7.0.1 branch

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants