Skip to content

Conversation

@benrr101
Copy link
Contributor

Description

This is a big PR! If you want me to split it up, I have a couple branches I could split it into! Just reject the PR and I'll do that!

At long last, the last (non-trivial) class merge! This mainly merges the SqlInternalConnectionTds class, but because there are multiple classes in the file, they have also been split up. Each commit is a single (or small collection) of members, so it can be reviewed one-commit-at-a-time. Each commit also has notes about what changes were made to the member.

The only non-trivial change made as part of this merge is to move the smaller classes in the file to a new Microsoft.Data.SqlClient.Connection namespace. It's unclear what they're used for unless you put them in a new namespace.

Issues

More or less finishes up #1261

Testing

Projects still build. I kinda expect a handful of test failures, but we'll sort that out as they happen.

…InBytes, _accessTokenCallback, _cleanSQLDNSCaching, _currentSessionData, _sessionRecoveryAcknowledged, _fedAuthRequired, _federatedAuthenticationAcknowledged, _federatedAuthenticationInfoReceived, _federatedAuthenticationInfoRequested, _federatedAuthenticationRequested, _sspiContextProvider, _activeDirectoryAuthTimeoutRetryHelper, _credential, _fedAuthFeatureExtensionData, _fedAuthToken, _loginAck, _parser, _poolGroupProviderInfo, _recoverySessionData, _serverSupportsDNSCaching, _sessionRecoveryRequested
…Supported, IsDnsCachingBeforeRedirectSupported, IsSQLDNSRetryEnabled
…JsonSupportEnabled, IsVectorSupportEnabled, pendingSQLDNSObject, _tceVersionSupported, _dbConnectionPool, _dbConnectionPoolAuthenticationContextKey, _newDbConnectionPoolAuthenticationContext
…nContextUnLockedRefreshTimeSpan, s_transientErrors
…tPacketSize, _identity, _instanceName, _originalDatabase, _originalLanguage, _fResetConnection, CurrentSessionData
…nation, _threadIdOwningParserLock, _timeout, _timeoutErrorInternal, TimeoutErrorInternal
…ction, Identity, OriginalClientConnectionId, PendingTransaction, RoutingDestination, RoutingInfo, IsTransientError()
…e, Is2008OrNewer, IsLockedForBulkCopy, PacketSize, Parser, PoolGroupProviderInfo, ServerProcessId (made internal), ServerProvidedFailoverPartner, ReadyToPrepareTransaction

# Conflicts:
#	src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
#	src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
(split long lines, added parameter labels to literals, replaced ad-hoc SQL with string interpolation)
(Split long lines, adopt netcore style trave event formatting, use null propagation for parser.disconnect, move comments around)
(remove redundant parantheses, split long lines, moved a couple comments)
(split long lines, flip enum comparison operands, add parameter labels for constant)
(diff denoted by #if NETFRAMEWORK, rebalance comments)
(rebalance comments, flip comparison with constant operands)
(split long lines, rebalanced comments)
(rewrote disconnectransaction into a single line)
(use `is Enum or Enum` pattern, chop argument list)
(make private, split long lines, rebalance comments)
…actionEnded (redundant override)

(split long lines)
(labels for constant parameters, split long lines, adopt netcore style trace event strings)
(split long lines, rebalanced comments)
(split long lines, introduce temp variable for source type b/c the ternary was was too long to use in-line, reorder temp variable declaration order to group similar variables)
(extract exception number checks to variable, comment to xmldocs)
(resolve conflicts with #if, split long lines, rebalance comments, introduce some ternaries, nothing too crazy)
@benrr101 benrr101 added this to the 7.0.0-preview3 milestone Nov 12, 2025
@benrr101 benrr101 requested a review from a team as a code owner November 12, 2025 18:43
Copilot AI review requested due to automatic review settings November 12, 2025 18:43
@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Nov 12, 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 completes a major refactoring by merging the platform-specific SqlInternalConnectionTds implementations into a single shared file. The main accomplishment is consolidating the last non-trivial class merge for the SqlClient codebase.

Key Changes

  • Merged SqlInternalConnectionTds from netfx and netcore into a single common implementation
  • Introduced new Microsoft.Data.SqlClient.Connection namespace for helper classes (ServerInfo, SessionData, SessionStateRecord)
  • Changed ThreadMayHaveLock() from method to property for consistency
  • Fixed spelling error in SqlException.cs
  • Removed stub files that were used during the merge process
  • Updated project files to reference the new shared implementation

Reviewed Changes

Copilot reviewed 13 out of 16 changed files in this pull request and generated 22 comments.

Show a summary per file
File Description
SqlInternalConnectionTds.cs New merged implementation of the core TDS connection class with 3688 lines, consolidating netfx and netcore versions
Connection/SessionData.cs Moved to new namespace, contains session state management logic
Connection/SessionStateRecord.cs Moved to new namespace, represents individual session state records
Connection/ServerInfo.cs Moved to new namespace, contains server connection information
SqlException.cs Added new overload for creating exceptions with single SqlError, fixed spelling error
TdsParser.cs Updated using statements and property access to match API changes
TdsParserStateObject.cs Updated property access from method call to property
SqlConnection.cs, SqlConnectionFactory.cs, SspiContextProvider.cs Added using statement for new Connection namespace
netfx/netcore project files Updated to reference shared files instead of platform-specific ones

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.

Since the new SqlInternalConnectionTds.cs is 3688 lines long, most of which I assume are identical to the two previous files, it would be helpful to have the functional differences called out. There are too many commits for reviewers to walk through and try to keep track of it all IMO.

@paulmedynski paulmedynski self-assigned this Nov 13, 2025
@benrr101
Copy link
Contributor Author

@paulmedynski since I called out in bold at the beginning of the PR description that the PR is big and can be split up if necessary and that if you want it smaller you should reject it, I will trust you read that and decided not to reject because you are ok with it being a very big PR. I called out code changes in the commit comments themselves, but I can scrub them again and check for "functional changes" to call out.

Copy link
Contributor Author

@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.

Adding comments that call out less-trivial changes. There are no true "functional" changes here, just tweaks to formatting.

* Use string.Format again for UserServerName assignment in ServerInfo.cs
* Make fields readonly that were called out by copilot
* Fixed typo in comment for _dbConnectionPoolAuthenticationContextKey
* Restored TODO comment from @mdaigle
* Added `using` for cancellation token source in the middle of active directory junk
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.

Thanks for the comments - very helpful! A couple of suggestions, but not blocking.

@benrr101 benrr101 merged commit ad5687e into main Nov 14, 2025
265 checks passed
@benrr101 benrr101 deleted the dev/russellben/merge/sqlconnectiontds branch November 14, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Common Project 🚮 Things that relate to the common project project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants