Deprecate TransparentNetworkIPResolution - #4576
Conversation
Partially implements dotnet#4494 (deprecation only; no default changes). - Mark SqlConnectionStringBuilder.TransparentNetworkIPResolution obsolete in both the implementation and the reference assembly, pointing callers at MultiSubnetFailover and noting that TNIR is .NET Framework-only. - Suppress the resulting obsolete warnings at the internal call sites in SqlConnectionStringBuilder and in tests that exercise the keyword. - Document the deprecation in the SqlConnection and SqlConnectionStringBuilder doc snippets. Connection string defaults are intentionally unchanged in this version: TransparentNetworkIPResolution still defaults to true on .NET Framework and MultiSubnetFailover still defaults to false. Flipping those defaults and adding the associated compatibility switches is deferred. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements the first (non-breaking) step of deprecating Transparent Network IP Resolution (TNIR) by marking SqlConnectionStringBuilder.TransparentNetworkIPResolution obsolete on the .NET Framework-only API surface, suppressing resulting internal/test build warnings, and updating documentation to recommend MultiSubnetFailover.
Changes:
- Marked
SqlConnectionStringBuilder.TransparentNetworkIPResolutionas obsolete in the implementation and reference assembly. - Added targeted
CS0618suppressions at internal keyword-dispatch call sites and in netfx-gated tests that set the property. - Updated doc snippets to label TNIR as deprecated and point to
Multi Subnet Failover/MultiSubnetFailover.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/SNICloseRaceDeadlockTest.cs | Suppresses obsolete warnings for TNIR usage in netfx-gated simulated server deadlock test setup. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/SNICloseHandshakeCancellationTest.cs | Suppresses obsolete warnings for TNIR usage in netfx-gated handshake cancellation test setup. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/SNICloseDeadlockTest.cs | Suppresses obsolete warnings for TNIR usage in multiple netfx-gated simulated server deadlock scenarios. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs | Suppresses obsolete warnings for TNIR usage in simulated server connection tests. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTests.cs | Suppresses obsolete warnings for TNIR usage in routing-related simulated server tests. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs | Suppresses obsolete warnings for TNIR usage in simulated failover tests. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs | Adds [Obsolete] to the TNIR property and suppresses CS0618 in internal keyword dispatch. |
| src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.cs | Updates the reference assembly surface with ObsoleteAttribute for the TNIR property (netfx-only). |
| doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml | Documents TNIR as obsolete and recommends MultiSubnetFailover, including the modern-.NET unsupported behavior note. |
| doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml | Labels TNIR keyword as deprecated and recommends Multi Subnet Failover in the connection string keyword table. |
Suppressed comments (1)
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs:1090
- In the keyword setter dispatch, the added
#pragma warning disable 618around TransparentNetworkIPResolution doesn’t include a rationale comment (unlike the existing// Obsolete propertiessuppression just above). Please add a brief comment (or refactor the suppression scope) to document why CS0618 must be suppressed in this internal keyword plumbing.
#if NETFRAMEWORK
#pragma warning disable 618 // Obsolete properties
case Keywords.ConnectionReset:
ConnectionReset = ConvertToBoolean(value);
break;
#pragma warning restore 618
case Keywords.NetworkLibrary:
NetworkLibrary = ConvertToString(value);
break;
case Keywords.TransparentNetworkIPResolution:
#pragma warning disable 618
TransparentNetworkIPResolution = ConvertToBoolean(value);
#pragma warning restore 618
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…r ArgumentException - Add the existing '// Obsolete properties' rationale comment to the two new CS0618 suppressions around TransparentNetworkIPResolution so the intent matches the neighbouring ConnectionReset suppressions. - Use <xref:System.ArgumentException> instead of a backtick literal in the SqlConnection.xml keyword table, matching the file's existing convention. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 108f631b-430f-40a3-bd20-74f19527c192
The net462 legs failed to build with CS0618 because SqlConnectionOptionsTest sets SqlConnectionStringBuilder.TransparentNetworkIPResolution in two netfx-gated tests. These usages arrived on main after this branch was cut, so they were missing the suppressions applied to the other test files. Merged main into the branch so the build matches what CI compiles, and wrapped both call sites in the same '#pragma warning disable 618' pattern used elsewhere. Verified locally by building net462 with -p:TargetOs=Windows_NT for the UnitTests, FunctionalTests and ManualTests projects: all clean with 0 warnings. Confirmed the check is faithful by removing the pragmas and reproducing the exact CS0618 errors CI reported. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 108f631b-430f-40a3-bd20-74f19527c192
The pragma-wrapped assignment lost its block-scope indentation, making it inconsistent with the matching tnirInConnString block below. The diff against main is now purely additive. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 108f631b-430f-40a3-bd20-74f19527c192
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml:1420
- In the new note, the sentence “Transparent Network IP Resolution is supported only on .NET Framework; on .NET the keyword is not recognized …” is a bit ambiguous in this property’s docs (the property itself is NETFRAMEWORK-only). Consider rewording to explicitly refer to the connection-string keyword usage on .NET (e.g., “If the keyword is present in a connection string on .NET, it is not recognized and throws ArgumentException.”) to avoid implying the property exists but is unsupported on .NET.
<para>
This property is obsolete. Use <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MultiSubnetFailover" /> instead. Transparent Network IP Resolution is supported only on .NET Framework; on .NET the keyword is not recognized and throws an <see cref="T:System.ArgumentException" />.
</para>
…arakeet # Conflicts: # doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml
Matches the convention used elsewhere in SqlConnection.xml so the type reference stays linkable in generated docs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 108f631b-430f-40a3-bd20-74f19527c192
Description
Addresses #4494
TransparentNetworkIPResolution(TNIR) is the more error-prone of two overlapping "connect faster across multiple DNS-resolved IPs" strategies. It is only available on .NET Framework (setting it on modern .NET throwsArgumentException), and even on .NET Framework the driver already silently ignores it for Azure SQL endpoints, any Microsoft Entra ID auth method, andAccessToken.MultiSubnetFailovercovers the same goal, works consistently on all target frameworks, and is the documented strategy for Always On availability group listeners.This PR takes the first, non-breaking step of the staged deprecation described in #4494: it marks the API obsolete and documents the recommended alternative.
What this changes:
[Obsolete]toSqlConnectionStringBuilder.TransparentNetworkIPResolutionin both the implementation and the reference assembly. The message points callers atMultiSubnetFailoverand notes that TNIR is .NET Framework-only.CS0618at the two internal call sites inSqlConnectionStringBuilder(theGetAtandSetValuekeyword dispatch) and in the netfx-gated tests that set the property. These are internal plumbing that must keep working for the keyword to function at all, so suppression is the correct treatment rather than removal.SqlConnectionandSqlConnectionStringBuilderdoc snippets.Explicitly out of scope: no behavior changes. Connection string defaults are untouched. TNIR still defaults to
trueon .NET Framework andMultiSubnetFailoverstill defaults tofalse. No new AppContext switches are introduced. Flipping those defaults, along with the associated compatibility switches, is deferred to a future major version so this change carries no runtime risk and no migration burden.The only reviewer-visible consequence is a new build warning for consumers who reference the property. That is the intended signal for a staged deprecation, and callers can suppress it or migrate to
MultiSubnetFailoverat their own pace.Issues
Partially addresses #4494 (item 1: mark TNIR obsolete on the public API surface). Items 2 and 3 of that issue, flipping the TNIR and
MultiSubnetFailoverdefaults, are intentionally not included here.Testing
No new tests were added, which is appropriate here: this change adds no new runtime behavior to cover. An
[Obsolete]attribute is a compile-time signal, and the existing test suite already validates that the keyword continues to parse and round-trip correctly. Those existing tests now double as a regression check that the attribute did not break the keyword.Validation performed:
Microsoft.Data.SqlClientbuilds clean fornet8.0with 0 warnings and 0 errors. The repository setsTreatWarningsAsErrors=true, so the pragma placement is confirmed correct for the paths that compile on this host.SqlConnectionOptionsTest,LocalAppContextSwitchesTest).DataDirectorypath tests) on this macOS dev machine.Gap worth flagging for review:
net462cannot be compiled on macOS, so the#pragma warning disable 618suppressions added inside#if NETFRAMEWORKblocks (the builder call sites and the netfx-gated test usages) are unverified locally and rely on CI to confirm.Guidelines
Please review the contribution guidelines before submitting a pull request: