Remove extra connection options parameters#4261
Merged
Merged
Conversation
Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request simplifies SqlClient’s internal connection-opening and pooling pathways by removing the redundant SqlConnectionOptions userOptions parameter from multiple internal methods/constructors, aligning call chains across pooled/non-pooled and sync/async flows.
Changes:
- Removed
userOptionsfrom internal open/replace/get-connection APIs (DbConnectionInternal/DbConnectionClosed/SqlConnectionInternal→SqlConnectionFactory→IDbConnectionPoolimplementations). - Updated
IDbConnectionPooland both pool implementations (wait-handle + channel-based) to the new signatures. - Updated unit tests to use the simplified pool API surface.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs | Updates unit tests to call pool APIs without SqlConnectionOptions. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/TransactedConnectionPoolTest.cs | Updates mock IDbConnectionPool implementation signatures to match interface changes. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/ChannelDbConnectionPoolTest.cs | Updates tests to remove SqlConnectionOptions arguments from pool calls. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs | Removes userOptions threading through connection creation/open paths and pool calls. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs | Updates open logic to call TryOpenConnection/TryReplaceConnection without UserConnectionOptions. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs | Removes userOptions from pending/open/create APIs and replaces usages with simplified calls. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/IDbConnectionPool.cs | Simplifies interface by removing userOptions from TryGetConnection and ReplaceConnection. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/ChannelDbConnectionPool.cs | Updates interface implementation and removes userOptions plumbing from internal open logic. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs | Removes optional userConnectionOptions parameter and associated NETFRAMEWORK permission-demand block. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs | Updates internal open pipeline to no longer pass userOptions into factory/pool methods. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs | Updates closed-state open/replace paths to match the simplified method signatures. |
cheenamalhotra
approved these changes
May 7, 2026
apoorvdeshmukh
approved these changes
May 7, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4261 +/- ##
==========================================
- Coverage 65.96% 64.56% -1.41%
==========================================
Files 275 270 -5
Lines 42993 65777 +22784
==========================================
+ Hits 28361 42468 +14107
- Misses 14632 23309 +8677
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
paulmedynski
pushed a commit
that referenced
this pull request
May 7, 2026
cheenamalhotra
pushed a commit
that referenced
this pull request
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the connection management code to simplify method signatures and remove the use of the
SqlConnectionOptions userOptionsparameter from internal APIs and connection pool implementations. The main goal is to streamline the process of opening and replacing connections, making the codebase easier to maintain and less error-prone.Connection Management API Simplification:
SqlConnectionOptions userOptionsparameter from the signatures ofTryOpenConnection,TryReplaceConnection, and related methods inDbConnectionInternal,DbConnectionClosed, andSqlConnectionInternal. All internal logic and calls have been updated accordingly. [1] [2] [3] [4] [5]TryOpenConnectionInternaland its callers to no longer require or passuserOptions. [1] [2]Connection Pool Interface and Implementation Updates:
IDbConnectionPoolinterface by removing theuserOptionsparameter fromTryGetConnectionandReplaceConnection, and updated all implementing classes (ChannelDbConnectionPool,WaitHandleDbConnectionPool) to match the new signatures. [1] [2] [3] [4] [5] [6]userOptionsargument, including internal helper methods such asOpenNewInternalConnectionandGetInternalConnection. [1] [2] [3] [4] [5]Code Clean-up and Comments:
userConnectionOptions, including .NET Framework-specific permission demand logic that is no longer relevant. [1] [2] [3]New tests for CAS Functionality
These changes collectively modernize and clarify the connection handling logic, reducing unnecessary complexity and improving maintainability.