Skip to content

Add application identity to USERAGENT payload (V2) - #4632

Open
cheenamalhotra wants to merge 12 commits into
mainfrom
dev/cheena/refactored-pancake
Open

Add application identity to USERAGENT payload (V2)#4632
cheenamalhotra wants to merge 12 commits into
mainfrom
dev/cheena/refactored-pancake

Conversation

@cheenamalhotra

@cheenamalhotra cheenamalhotra commented Sep 2, 2026

Copy link
Copy Markdown
Member

Fixes #3201

Implements USERAGENT payload version 2, per the SQL Drivers User Agent V2 spec.

Summary

Version 2 adds two parts to the login USERAGENT feature extension:

  • Application Id — identifies the middleware using the driver (EF Core, SSMS, DacFx, Semantic Kernel, ...), so partner usage can be told apart from direct SqlClient use.
  • Driver Properties — a driver-owned flag field for SqlClient's own feature tracking. Currently reports whether connection pool V2 is enabled.

The application id comes from an enum rather than a free-form string, so applications cannot inject arbitrary text into the telemetry payload.

API

public enum SqlClientApp
{
    Unknown = 0x0000,   // default
    EntityFramework = 0x0001,
    SemanticKernel = 0x0002,
    ManagementStudio = 0x0003,
    SqlManagementObjects = 0x0004,
    DataTierApplicationFramework = 0x0005,
    SqlToolsService = 0x0006,
    AspNetCoreDistributedSqlServerCache = 0x0007,
    EntityFramework6 = 0x0008,
    AzureFunctionsSqlExtension = 0x0009,
    OrleansAdoNet = 0x000A,
    DurableTaskSqlServer = 0x000B,
    SqlPackage = 0x000C
}

public class SqlConnection
{
    public SqlClientApp SqlClientAppId { get; set; }
}

Reserved ranges:

Range Use
0x0001-0x7FFF Microsoft-defined large-scale apps
0x8000-0xBFFF Small-scale use
0xC000-0xFFFF Public / developer use

Set the property before opening the connection. An id that is not in the enum yet can still be reported by casting, so an app assigned an id after a driver release does not have to wait for a new build. Values outside the 16-bit range throw ArgumentOutOfRangeException rather than being silently truncated at login.

Payload

Version part bumped 1 -> 2, and the payload is now 9 parts. Both new parts are always sent, as 4 uppercase hex characters:

2|MS-MDS|{Driver Version}|{Arch}|{OS Type}|{OS Info}|{Runtime Info}|{App Id}|{Driver Properties}

For example:

2|MS-MDS|7.0.0|X64|Windows|Microsoft Windows 10.0.26100|.NET 9.0.4|0001|0001

With no app id set, part 8 is 0000.

Notes

  • This is telemetry. It is client-supplied and must not be used for security decisions.
  • The app id is not part of the pool key. Under pooling a connection reports the id of whichever connection opened the underlying physical connection, and connections opened in the background to reach Min Pool Size report Unknown. Treat this as indicative rather than exact attribution. Partitioning the pool per app id was considered and rejected — it would cost real connections to buy telemetry precision.
  • Renames SqlClientAgent to SqlClientApp and replaces the static RegisterSqlClientAgent method from the earlier revision of this PR. App.config registration is also dropped — it only had meaning while registration was process-wide and once-only. Neither has shipped.

Checklist

  • Tests added or updated
  • Public API changes documented
  • Verified against customer repro (n/a)
  • Ensure no breaking changes introduced

Adds an optional agent identifier to the USERAGENT login feature extension
so known middleware (EF Core, SSMS, DacFx, ...) can be told apart from
direct SqlClient use.

- New public `SqlClientAgent` enum and
  `SqlConnection.RegisterSqlClientAgent(SqlClientAgent)`.
- Registration is process-wide and allowed once, so an application cannot
  overwrite or spoof an agent set by a library.
- Can also be set from App.config via a `SqlClientAgent` section.
- Payload format bumped to version 2; the agent id is appended as an
  optional 8th part only when registered.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI balanced review requested due to automatic review settings September 2, 2026 19:20
@cheenamalhotra
cheenamalhotra requested a review from a team as a code owner September 2, 2026 19:20
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Sep 2, 2026
@cheenamalhotra cheenamalhotra added this to the 7.1.0 milestone Sep 2, 2026
@cheenamalhotra cheenamalhotra added the Public API 🆕 Issues/PRs that introduce new APIs to the driver. label Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The LOGIN7 length race, enum validation, test isolation, and documentation issues remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds process-wide middleware identification to the USERAGENT login payload.

Changes:

  • Adds SqlClientAgent registration and configuration APIs.
  • Extends USERAGENT v2 with an optional agent ID.
  • Adds tests, documentation, and samples.
File summaries
File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/UserAgentTests.cs Tests payload versioning and agent encoding.
src/Microsoft.Data.SqlClient/tests/UnitTests/SqlClientAgentTests.cs Tests identifiers and configuration parsing.
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs Verifies LOGIN7 agent transmission.
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientAgentConfigurationTests.cs Tests configuration precedence.
src/Microsoft.Data.SqlClient/tests/FunctionalTests/app.config Registers the test agent.
src/Microsoft.Data.SqlClient/src/Resources/Strings.resx Adds registration error messages.
src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs Exposes generated resource accessors.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs Builds and caches agent payloads.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs Writes agent payloads into LOGIN7.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs Creates agent-related exceptions.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs Adds the registration API.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Defines agents and registration logic.
src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.cs Updates the public API contract.
doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml Documents registration behavior.
doc/samples/SqlConnection_RegisterSqlClientAgent.cs Demonstrates middleware registration.
Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (1)

src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientAgentConfigurationTests.cs:20

  • The test intent is written as ordinary comments, but test methods require XML <summary> documentation. Convert this explanation to an XML summary so the new test follows the test documentation contract.
        [ConditionalFact(typeof(TestUtility), nameof(TestUtility.IsNetFramework))]
        public void AppConfigAgent_PreventsProgrammaticRegistration()
  • Files reviewed: 14/15 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Outdated
- Capture the USERAGENT payload once in SendPreLoginHandshake and pass it
  to WriteLoginData, so a concurrent registration cannot make the reserved
  feature length disagree with the bytes written.
- Restrict RegisterSqlClientAgent to declared enum members. Undeclared
  numeric ids remain valid in config, where forward compatibility matters.
- Serialize ConnectionTests via SimulatedServerTestCollection; it now
  mutates process-wide registration.
- Add XML summary to SqlClientAgentConfigurationTests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 2, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Malformed App.config handling needs isolated regression coverage before approval.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs:198

  • The new tests validate Parse directly, but none exercises this catch through LoadFromAppConfig. Consequently, the stated guarantee that an invalid or malformed application configuration cannot turn first use into a TypeInitializationException has no regression coverage. Add an isolated-process/AppDomain test with a bad SqlClientAgent section that triggers registration loading and verifies the failure is consumed.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs:39

  • Value is always built with agentId: null, so it never has the optional eighth part; only GetUcs2Bytes can return that transmitted form. Describing the Value property itself with the optional format makes its contract inconsistent with the implementation and the seven-part tests. Clarify that this is the base value and that the encoded login payload may append the agent ID.
    ///     The format is pipe ('|') delimited into 7 parts, plus an optional
    ///     8th part:
    ///
    ///     <code>2|MS-MDS|{Driver Version}|{Arch}|{OS Type}|{OS Info}|{Runtime Info}[|{Agent Id}]</code>

src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientAgentConfigurationTests.cs:24

  • Convert the preceding ordinary comment into an XML <summary> for this test method. The repository's test documentation rules require behavior-focused XML summaries on every test method.
        [ConditionalFact(typeof(TestUtility), nameof(TestUtility.IsNetFramework))]
        public void AppConfigAgent_PreventsProgrammaticRegistration()
  • Files reviewed: 14/15 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

- Change SqlClientAgent to int-backed so it needs no CLSCompliant
  attribute, which the notsupported assembly rejects (CS3021). Identifiers
  are still bounded to a positive 16-bit range.
- Extract LoadAgent so the configuration failure paths are testable, and
  cover malformed config, invalid id, wrong section type, missing section,
  and a throwing loader.
- Clarify that UserAgent.Value never carries the agent id; only the login
  payload does.
- Convert the App.config test comment to an XML summary.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 2, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The public enum’s underlying type and CLS annotations do not match the advertised 16-bit API contract.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file
  • Files reviewed: 14/15 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Outdated
- Remove the now-unnecessary CLSCompliant attribute from the
  implementation method.
- Document the 16-bit identifier contract on the enum, since it is no
  longer implied by the underlying type.
- Assert the underlying type is Int32 so the CLS-compliant surface cannot
  regress.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 2, 2026 19:56
@cheenamalhotra cheenamalhotra moved this from To triage to In review in SqlClient Board Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Public API, configuration, and wire-payload changes require final human review, and two documentation nits remain.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (2)

src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.cs:603

  • The PR's API example still declares SqlClientAgent : ushort, but this public surface (and UnderlyingType_IsInt32) intentionally publishes an Int32-backed enum. Please update the PR description to omit : ushort or use : int, so consumers are not given an API signature that differs from the assembly.
public enum SqlClientAgent

src/Microsoft.Data.SqlClient/tests/UnitTests/UserAgentTests.cs:221

  • Document the bytes parameter and return value for this new test helper. The repository's test documentation rules require XML <param> and <returns> elements for helper methods where applicable.
    /// <summary>
    /// Decode a UCS-2 encoded payload back to its string form.
    /// </summary>
    private static string Decode(ReadOnlyMemory<byte> bytes) =>
  • Files reviewed: 14/15 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

doc/samples builds against the published Microsoft.Data.SqlClient package,
so it cannot reference an API that has not shipped yet. Move the example
into the XML docs alongside the existing App.config example and drop the
compiled sample file.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 2, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The PR description incorrectly documents SqlClientAgent as having a ushort underlying type.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs:23

  • The PR's API example still advertises public enum SqlClientAgent : ushort, while this declaration, the reference surface, and the new underlying-type test intentionally publish Int32. Because the enum's underlying type is observable, update the PR description to show public enum SqlClientAgent (or : int) and describe 16 bits as the validated identifier range rather than the underlying type.
public enum SqlClientAgent
  • Files reviewed: 13/14 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@cheenamalhotra

Copy link
Copy Markdown
Member Author

CI failure analysis — none of the 6 failing legs are caused by this change.

sqlclient-pr (4 legs: linux net8/net9, windows net9/net10)
All four fail on the same test, SqlCommandCancelTest.CancelAndDisposePreparedCommand_Tcp, with a server-side error:

Transaction (Process ID nn) was deadlocked on lock resources with another process and has been chosen as the deadlock victim.

The test runs a 6-way cross join over sys.objects, so it takes catalog locks and deadlocks when parallel legs run DDL against the same shared database. Known flaky area — the last two commits to this file are "Address additional flaky tests" (#4305) and "Address flaky DEBUG assertions" (#4085).

PR-SqlClient-Project (2 legs) — both fail before any test runs:

  • MacOSLatest_Sql25 net9_ManagedSNI_3: the Configure SQL Server [macOS] setup task exits 1.
  • Win22_Azure_Sql net9_NativeSNI_3: Build AKV Provider hits MSB4166: Child node "2" exited prematurely / Restore canceled! (agent/MSBuild crash, 4m runtime).

Why this change can't be the cause: it only appends an optional 8th part to the LOGIN7 USERAGENT payload. No manual test references UserAgent/USERAGENT or asserts on the payload format, and none of these failures touch login. The equivalent legs that do exercise this code all pass, including all three Win11_ARM64_Azure_Sql net462 legs which validate the new App.config path on .NET Framework.

Re-running to clear the flakes.

@saurabh500 saurabh500 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left some comments about the enum and API related questions.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The public documentation needs a security warning, and the PR description must accurately reflect the published API contract.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (3)

doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml:2328

  • The public API documentation omits the PR's important constraint that this identifier is client-supplied telemetry and must not be trusted for security decisions. Because any application can call this public method (and can select any declared agent), add that warning explicitly to prevent downstream consumers from treating the value as authenticated identity.
      <remarks>
        <para>
          This API is intended only for approved middleware partners. Applications should not call it directly.
        </para>

src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.cs:1048

  • The PR description still advertises a ushort-backed enum and a void registration method whose later calls throw, but the published surface is now an int-backed enum with a bool method that returns false on later calls. Please update the API block and registration semantics in the PR description so consumers and release-note authors see the actual contract.
    /// <include file='../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/RegisterSqlClientAgent/*' />
    public static bool RegisterSqlClientAgent(Microsoft.Data.SqlClient.SqlClientAgent id) { throw null; }

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs:386

  • The PR description still advertises public enum SqlClientAgent : ushort, a void registration method, and InvalidOperationException on later registration, while the published API is now an int-backed enum and this method returns false. Please update the description/API example and registration semantics so consumers do not review or adopt the wrong public contract.
        public static bool RegisterSqlClientAgent(SqlClientAgent id)
            => SqlClientAgentRegistration.Register(id);
  • Files reviewed: 14/15 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@cheenamalhotra

Copy link
Copy Markdown
Member Author

Both review comments are addressed in 9c7f4b0.

  • Register no longer throws when it loses. RegisterSqlClientAgent returns booltrue if the call registered the agent, false if one was already registered. First registration still wins and still cannot be replaced, but a second middleware no longer faults the host app. Invalid identifiers still throw ArgumentOutOfRangeException. Dropped the now-unused SQL_SqlClientAgentAlreadyRegistered resource and added Register_ReportsWhetherItWon.
  • Cancel test no longer touches the catalog. NOLOCK was the wrong fix — it still takes Sch-S locks and adds an error 601 failure mode. The result set now comes from constant row sets (16^6 = 16.7M rows), so there is no catalog interaction at all and it stays a single prepared SELECT.

CI: 208 checks pass, including all 7 sqlclient_manual_azure_123_* legs (the deadlock is gone), every net462 leg, and sqlclient_functional_windows_net462 which covers the App.config path under the new return-value contract.

The only red is MacOSLatest_Sql25 net8_ManagedSNI_1 / net9_ManagedSNI_3, both failing in the Configure SQL Server [macOS] setup task before any test runs — the SQL Server container crashes and core-dumps inside the Lima VM on the macOS agent. I have re-run this three times now; the affected legs move around each time, which is agent instability rather than a test defect. That one needs infra access.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientAgent.cs Outdated
Replace the process-wide agent registration with a per-connection
application identity, matching the updated USERAGENT V2 spec.

The payload now carries nine parts. The App Id and the driver-owned
Driver Properties parts are always present, each written as four
uppercase hexadecimal characters:

  2|MS-MDS|6.1.3|X64|Windows|...|.NET 9.0.4|0000|0001

- SqlConnection.RegisterSqlClientAgent is replaced by the
  SqlConnection.SqlClientAppId property, set before the connection is
  opened. Values outside the 16-bit range are rejected rather than
  silently truncated at login.
- SqlClientAgent is renamed to SqlClientApp. The enum keeps the default
  int backing so it stays CLS-compliant, and unregistered identifiers
  can still be reported by casting.
- SqlClientDriverProperties tracks driver-owned feature flags, starting
  with connection pool V2 enablement.
- App.config registration is removed. It only had meaning while
  registration was process-wide and once-only.

Public type documentation lives in doc/snippets, per repo convention.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 3, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Moderate API-contract, pooling, cloning, payload-format, and test-coverage issues remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (1)

src/Microsoft.Data.SqlClient/src/Resources/Strings.resx:2204

  • This key is absent from every localized Strings.*.resx file, while their key sets otherwise match the base file (for example, Strings.de.resx:2199-2204, Strings.fr.resx:2199-2204, and Strings.ja.resx:2199-2204). Add the corresponding satellite entries so localized applications do not fall back to English for this new public exception.
  <data name="SQL_InvalidSqlClientAppId" xml:space="preserve">
    <value>The SqlClient application identifier '{0}' is outside the supported range of 0 to 65535.</value>
  </data>
  • Files reviewed: 17/18 changed files
  • Comments generated: 6
  • Review effort level: Balanced

@cheenamalhotra cheenamalhotra changed the title Add SqlClient agent identifier to USERAGENT payload Add application identity to USERAGENT payload (V2) Sep 3, 2026
- SqlConnection(SqlConnection) now copies the application identity, so
  ICloneable.Clone no longer resets a configured identity to Unknown.
- Add SqlClientApp.SqlPackage. sqlpackage builds on the Data-Tier
  Application Framework but reports its own identifier so command-line
  use can be told apart from other callers of that framework.
- Split the driver properties mapping out of the switch it reads, so the
  mapping can be tested. The switches are cached for the life of the
  process, which makes them impractical to vary in a test.
- Document how the identity behaves under pooling. It is not part of the
  pool key, so a pooled connection reports the identity that created the
  physical connection, and connections opened in the background to
  satisfy Min Pool Size report Unknown.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 3, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Multiple moderate API, login propagation, documentation, and localization issues remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs:1362

  • The registration API no longer exists, so concurrent registration cannot occur here. Keep the useful consistency rationale without referring to the removed process-wide agent model.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs:530

  • This comment still describes the removed Agent Id model and calls the field optional, but V2 now always appends both App Id and Driver Properties. Update it so the source documentation matches the implemented nine-part payload.
    // Version 2 adds the optional Agent Id part.
    private const string PayloadVersion = "2";
  • Files reviewed: 17/18 changed files
  • Comments generated: 4
  • Review effort level: Balanced

Comment thread src/Microsoft.Data.SqlClient/src/Resources/Strings.resx
- SqlClientAppId now rejects being set once the connection is connecting
  or open, matching AccessToken and the other login-time properties. The
  identity is only reported during login, so allowing a later change let
  the getter report a value that was never sent.
- Propagate the identity to the preliminary SQL Express connection used
  to discover the user instance name. That connection performs its own
  physical login, which was reported as Unknown.
- Add SQL_InvalidSqlClientAppId to the localized resource files, which
  are otherwise key-synchronized with the neutral file. The value is the
  neutral text pending localization.
- Drop two comments describing the removed process-wide agent model.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 3, 2026 22:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The public API documentation and release notes remain incomplete.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Suppressed comments (2)

doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml:2324

  • Carry the trust boundary from the PR contract into the public API documentation. This identifier is entirely client-supplied (including arbitrary in-range casts), so server-side consumers must not treat it as an authenticated identity or use it for authorization decisions.
      <remarks>
        <para>
          This API is intended for registered applications that reserve an identifier in
          <see cref="T:Microsoft.Data.SqlClient.SqlClientApp" />. An unregistered identifier may be reported by casting
          a value to that type, provided it is within the 16-bit range the protocol allows.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientApp.cs:10

  • Add a release-note entry for this user-visible feature. This introduces a new public enum/property and changes the always-sent USERAGENT wire payload to version 2, but no file under release-notes/ describes either change, so package consumers will not discover the new API or protocol behavior from the repository's release documentation.
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/SqlClientApp/*' />
public enum SqlClientApp
  • Files reviewed: 30/31 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml
Record the InvalidOperationException the setter raises once the
connection is opening or open, and state that the identity is
client-supplied telemetry rather than an authenticated identity, so it
must not be used for authorization.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 3, 2026 22:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The protocol, public API, telemetry, and connection-lifecycle changes require final human validation.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file
  • Files reviewed: 30/31 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Comment thread src/Microsoft.Data.SqlClient/src/Resources/Strings.de.resx Outdated
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.70115% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.60%. Comparing base (7054399) to head (095d84e).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...qlClient/src/Microsoft/Data/SqlClient/UserAgent.cs 95.74% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4632      +/-   ##
==========================================
- Coverage   65.92%   64.60%   -1.32%     
==========================================
  Files         290      285       -5     
  Lines       44987    68038   +23051     
==========================================
+ Hits        29656    43958   +14302     
- Misses      15331    24080    +8749     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 64.60% <97.70%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

New resource strings are added only to the neutral Strings.resx; the
scheduled OneLocBuild run populates the satellite files. Adding them by
hand risks conflicting with that pipeline.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efbed43f-1014-45d7-a9f6-9f04711c281e
Copilot AI review requested due to automatic review settings September 4, 2026 00:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new resource key must be added to all localized satellite resource files.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file
  • Files reviewed: 17/18 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/Microsoft.Data.SqlClient/src/Resources/Strings.resx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Feature: New API to capture Client Information for telemetry

7 participants