Skip to content

Conversation

@mdaigle
Copy link
Contributor

@mdaigle mdaigle commented Nov 4, 2025

Description

Cleaned up properties in SqlInternalConnection to make them auto-properties, add summary doc comments, and remove consideration for old SQL Server versions (where applicable).

Should be reviewed commit by commit.

Testing

No logic changes. Existing tests should cover everything.

@mdaigle mdaigle marked this pull request as ready for review November 4, 2025 21:26
@mdaigle mdaigle requested a review from a team as a code owner November 4, 2025 21:26
Copilot AI review requested due to automatic review settings November 4, 2025 21:26
@mdaigle mdaigle added this to the 7.0.0-preview3 milestone Nov 4, 2025
Copy link
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 refactors the SqlInternalConnection class to improve code organization, maintainability, and consistency. The key changes include extracting the TransactionRequest enum to its own file, consolidating property definitions with better documentation, and standardizing naming conventions.

  • Extracts TransactionRequest enum from nested type to standalone file
  • Refactors SqlInternalConnection properties with comprehensive XML documentation
  • Standardizes casing for property names (PromotedDTCTokenPromotedDtcToken, IsAzureSQLConnectionIsAzureSqlConnection)

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
TransactionRequest.cs New standalone enum file for transaction request types
SqlInternalTransaction.cs Updated to use standalone TransactionRequest enum
SqlInternalConnection.cs Major refactoring with improved property organization, XML docs, and simplified expressions
SqlDelegatedTransaction.cs Updated references to TransactionRequest and PromotedDtcToken
WaitHandleDbConnectionPool.cs Replaced IsNonPoolableTransactionRoot with explicit logic
DbConnectionInternal.cs Removed IsNonPoolableTransactionRoot property
SqlInternalConnectionTds.cs (netfx & netcore) Removed override of IsNonPoolableTransactionRoot, updated property references
Microsoft.Data.SqlClient.csproj (netfx & netcore) Added TransactionRequest.cs to compilation
ChannelDbConnectionPoolTest.cs Added ActiveIssue attribute to flaky test
Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs:1500

  • These 'if' statements can be combined.
                if (!IsAzureSqlConnection)
                {
                    // If not a connection to Azure SQL, Readonly with FailoverPartner is not supported
                    if (ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly)
                    {
                        if (!string.IsNullOrEmpty(ConnectionOptions.FailoverPartner))
                        {
                            throw SQL.ROR_FailoverNotSupportedConnString();
                        }

                        if (ServerProvidedFailoverPartner != null)
                        {
                            throw SQL.ROR_FailoverNotSupportedServer(this);
                        }
                    }
                }

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs:1509

  • These 'if' statements can be combined.
                if (!IsAzureSqlConnection)
                {
                    // If not a connection to Azure SQL, Readonly with FailoverPartner is not supported
                    if (ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly)
                    {
                        if (!string.IsNullOrEmpty(ConnectionOptions.FailoverPartner))
                        {
                            throw SQL.ROR_FailoverNotSupportedConnString();
                        }

                        if (ServerProvidedFailoverPartner != null)
                        {
                            throw SQL.ROR_FailoverNotSupportedServer(this);
                        }
                    }
                }

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.58%. Comparing base (0e8ae37) to head (dfaa538).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...crosoft/Data/SqlClient/SqlInternalConnectionTds.cs 75.00% 1 Missing ⚠️
...crosoft/Data/SqlClient/SqlInternalConnectionTds.cs 75.00% 1 Missing ⚠️
.../Microsoft/Data/SqlClient/SqlInternalConnection.cs 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3743      +/-   ##
==========================================
- Coverage   76.78%   76.58%   -0.20%     
==========================================
  Files         273      272       -1     
  Lines       44914    44177     -737     
==========================================
- Hits        34487    33833     -654     
+ Misses      10427    10344      -83     
Flag Coverage Δ
addons 90.82% <ø> (ø)
netcore 76.64% <94.28%> (-0.14%) ⬇️
netfx 76.29% <94.28%> (+0.03%) ⬆️

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.

@paulmedynski paulmedynski self-assigned this Nov 5, 2025
Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

Looks good! I appreciate the changes!

@mdaigle mdaigle merged commit a19cec4 into main Nov 5, 2025
252 checks passed
@mdaigle mdaigle deleted the dev/mdaigle/cleanup-sqlinternalconnection branch November 5, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants