Skip to content

Conversation

benrr101
Copy link
Contributor

Description

This PR does two main changes:

  1. Reverts a small change in netfx SqlConnectionFactory class from Cleanup | Remove Dead SMI Code (Part 1) #3393.
    I thought it was a safe change to make, but I neglected to notice that the poolgroupproviderinfo was being passed in from the caller of the method. I noticed this issue while working on merging SqlConnectionFactory, since I made this change on the netfx version but not on the netcore version.
  2. Makes SqlConnectionFactory CreateConnection classes have strongly typed poolgroupproviderinfo arguments.
    Not sure why these were always being passed in as object, but they are now being passed in as DbConnectionPoolGroupProviderInfo, which is what they should have been from the beginning.

Issues

No issue currently correspond to these changes.

Testing

Well, it still builds. Kinda disappointed the initial issue didn't cause CI failures.

benrr101 added 2 commits June 12, 2025 17:18
Make pool provider info arguments in *ConnectionFactory methods strongly typed
@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 22:49
@benrr101 benrr101 requested a review from a team as a code owner June 12, 2025 22:49
@benrr101 benrr101 added Area\Netfx Issues that apply only to .NET Framework target runtime or the 'netfx' project folder. Code Health 💊 Issues/PRs that are targeted to source code quality improvements. labels Jun 12, 2025
Copy link
Contributor

@Copilot 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 restores the abstract signatures for pool provider info methods on the NetFX side and strengthens the typing of poolGroupProviderInfo across both NetFX and NetCore SqlConnectionFactory implementations.

  • Reverted CreateConnectionPoolGroupProviderInfo in NetFX to its abstract form so callers pass a strongly typed DbConnectionPoolGroupProviderInfo.
  • Updated all CreateConnection overloads in both NetFX and NetCore to accept DbConnectionPoolGroupProviderInfo instead of object.

Reviewed Changes

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

File Description
src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs Made CreateConnectionPoolProviderInfo and CreateConnectionPoolGroupProviderInfo abstract for strong typing.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs Changed constructor parameter from object providerInfo to DbConnectionPoolGroupProviderInfo and reformatted base call.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs Updated CreateConnection overrides to use DbConnectionPoolGroupProviderInfo, improved null‐propagation, and adjusted provider info propagation.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs Mirrored strong-typing changes and reformatted CreateConnection call to use named arguments for clarity.
Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs:58

  • Consider using 'as SqlConnection' instead of a direct cast to avoid an InvalidCastException if owningConnection is ever not a SqlConnection, matching the NetFX implementation.
SqlConnection sqlOwningConnection = (SqlConnection)owningConnection;

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs:94

  • [nitpick] Add an XML documentation comment for this abstract method to explain its purpose and parameters, improving the clarity of the public API.
internal abstract DbConnectionPoolProviderInfo CreateConnectionPoolProviderInfo(

@saurabh500
Copy link
Contributor

Not sure why these were always being passed in as object, but they are now being passed in as DbConnectionPoolGroupProviderInfo, which is what they should have been from the beginning.

In System.Data.dll which had ODBC/OleDB/(once OracleClient) and SqlClient, the base classes for conn pool were being used to manage pools for all the providers.
DbConnectionPoolGroupProviderInfo was provider specific class and which was being passed to provider specific pool implementation (ODBC pool would have its own quirks and so would OleDb).

The code you are modifying was passthrough, which needed to pass around an object.
Now that there is only SqlClient and its pool, the change you have made, makes sense.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

One question.

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 63.58%. Comparing base (2385ca7) to head (2c161c3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...c/Microsoft/Data/SqlClient/SqlConnectionFactory.cs 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #3417       +/-   ##
=========================================
+ Coverage      0   63.58%   +63.58%     
=========================================
  Files         0      299      +299     
  Lines         0    65418    +65418     
=========================================
+ Hits          0    41594    +41594     
- Misses        0    23824    +23824     
Flag Coverage Δ
addons 92.58% <ø> (?)
netcore 66.87% <100.00%> (?)
netfx 66.01% <60.00%> (?)

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

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

@benrr101 benrr101 merged commit 1058566 into main Jun 13, 2025
251 checks passed
@benrr101 benrr101 deleted the dev/russellben/fix-poolproviderinfo branch June 13, 2025 20:58
@paulmedynski paulmedynski added this to the 6.1-preview2 milestone Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area\Netfx Issues that apply only to .NET Framework target runtime or the 'netfx' project folder. Code Health 💊 Issues/PRs that are targeted to source code quality improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants