Repository navigation
Conversation
Consolidate partial classes Add references to Parser namespace
Add references to Parser namespace
Add references where necessary
Move is made wholesale to preserve history
Moved wholesale to retain file history
Move TdsParserStateObjectManaged to Parser namespace
This creates a stub namespace that native SNI will go into
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Several manual and stress-test reflection or stack-frame references still use the former parser namespaces and now fail or stop matching.
1 open finding
What changed in this PR
Reorganizes internal TDS parsing code into focused parser, login, token, and native-SNI namespaces without intentionally changing public behavior.
Changes:
- Splits legacy parser helpers into dedicated files and namespaces.
- Updates production and test references to relocated internal types.
- Extracts native handles and existing public enums into focused files.
| File | Description |
|---|---|
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ISniNativeMethods.cs |
Imports native-SNI handles. |
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethods.netcore.cs |
Imports native-SNI handles. |
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsArm64.netfx.cs |
Imports native-SNI handles. |
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsNotSupported.netfx.cs |
Imports native-SNI handles. |
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX64.netfx.cs |
Imports native-SNI handles. |
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX86.netfx.cs |
Imports native-SNI handles. |
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeWrapper.cs |
Uses relocated native handles. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs |
Imports login token type. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs |
Removes relocated metadata partials. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/ConnectionCapabilities.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/ServerInfo.cs |
Imports parser routing types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs |
Imports parser, login, and token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniCommon.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniError.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniLoadHandle.netcore.cs |
Imports parser and login types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsConnection.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsHandle.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniNpHandle.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniPacket.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniProxy.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniTcpHandle.netcore.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.netcore.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/NativeSni/SNIHandle.cs |
Extracts native connection handle. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/NativeSni/SNILoadHandle.cs |
Moves native SNI loader. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/NativeSni/SNIPacket.cs |
Extracts native packet handle. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/CallbackType.cs |
Extracts callback enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/DescribeParameterEncryptionResultSet1.cs |
Extracts result-set ordinals. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/DescribeParameterEncryptionResultSet2.cs |
Extracts result-set ordinals. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/DescribeParameterEncryptionResultSet3.cs |
Extracts result-set ordinals. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/LastIOTimer.cs |
Extracts I/O timer holder. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/EncryptionOptions.cs |
Extracts encryption options. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/FederatedAuthenticationFeatureExtensionData.cs |
Extracts federated-auth data. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/PreLoginHandshakeStatus.cs |
Extracts handshake status. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/PreLoginOptions.cs |
Extracts pre-login options. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/SqlFedAuthToken.cs |
Extracts federated-auth token. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/SqlLogin.cs |
Extracts login state. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Packet.cs |
Moves packet reconstruction helper. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/PacketHandle.netcore.cs |
Moves .NET packet handle. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/PacketHandle.netfx.cs |
Moves Framework packet handle. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/ParsingErrorState.cs |
Extracts parsing-error enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/RunBehavior.cs |
Extracts parser run behavior. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/SessionHandle.netcore.cs |
Moves .NET session handle. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/SessionHandle.netfx.cs |
Moves Framework session handle. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/SniContext.cs |
Extracts SNI context enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/SslProtocolHelpers.cs |
Extracts TLS warning helper. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsEnums.cs |
Moves TDS constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsOperationStatus.cs |
Extracts operation-status enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParameterSetter.cs |
Relocates parameter setter. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParser.cs |
Moves core TDS parser. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserSessionPool.cs |
Moves parser session pool. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserState.cs |
Extracts parser-state enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObject.Multiplexer.cs |
Moves multiplexer implementation. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObject.cs |
Moves parser session state. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObjectFactory.cs |
Moves parser-state factory. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObjectManaged.netcore.cs |
Moves managed parser state. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObjectNative.cs |
Moves native parser state. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStaticMethods.cs |
Moves parser utilities. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsRecordBufferSetter.cs |
Moves structured-value writer. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsValueSetter.cs |
Moves TDS value writer. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/MultiPartTableName.cs |
Extracts multipart-name parsing. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/RoutingInfo.cs |
Extracts routing-token data. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/SqlFedAuthInfo.cs |
Extracts federated-auth metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/SqlMetaDataPriv.cs |
Consolidates private metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/SqlMetaDataUdt.cs |
Extracts UDT metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/SqlMetaDataXmlSchemaCollection.cs |
Extracts XML metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/SqlReturnValue.cs |
Extracts return-value metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/_SqlMetaData.cs |
Extracts column metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/_SqlMetaDataSet.cs |
Consolidates metadata-set logic. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/_SqlMetaDataSetCollection.cs |
Extracts metadata collection. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/_SqlRPC.cs |
Extracts RPC state. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.cs |
Imports parser/native-SNI types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiContextProvider.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs |
Imports parser metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCollation.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Batch.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.NonQuery.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Reader.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Xml.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandColumnEncryptionSetting.cs |
Extracts existing public enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionAttestationProtocol.cs |
Extracts existing public enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionColumnEncryptionSetting.cs |
Extracts existing public enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionIPAddressPreference.cs |
Extracts existing public enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionOptions.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionOverrides.cs |
Extracts existing public enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCredential.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDbColumn.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlEnums.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlEnvChange.cs |
Imports token metadata. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetaDataFactory.DataTypes.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlTransaction.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs |
Imports parser constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs |
Removes relocated TDS constants. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs |
Removes relocated setter. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs |
Removes split-out helpers. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TransactionRequest.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TransparentNetworkResolutionState.cs |
Extracts TNIR state enum. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs |
Imports parser types. |
src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj |
Updates relocated compile paths. |
src/Microsoft.Data.SqlClient/tests/FunctionalTests/MultiplexerTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/FunctionalTests/TdsParserStateObject.TestHarness.cs |
Moves harness namespace. |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionHelper.cs |
Updates reflected parser names. |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/TdsParserHelper.cs |
Updates reflected parser name. |
src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/DbConnectionPoolAccessTokenTest.cs |
Imports login namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/Common/AdapterUtilTest.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/ManagedSni/SniPacketTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlBulkCopyVariantTests.cs |
Imports parser token types. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlMetaDataFactoryDataTypesTest.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlMetaDataSetTest.cs |
Imports token namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/StateSnapshotPacketRecyclingTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/TdsParserStateObjectNativeTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/FeatureExtAckBoundsTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/IsolationLevelResetTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/TdsTokenBoundsTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/TdsParserDecimalTests.cs |
Imports parser namespace. |
src/Microsoft.Data.SqlClient/tests/UnitTests/TdsParserInternalsTest.cs |
Imports parser namespace. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| using System; | ||
| using System.Data; | ||
|
|
||
| namespace Microsoft.Data.SqlClient.Parser.Tokens; |
This branch has not been deployed
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.

Description
Refactors the TDS parser implementation into focused files and namespaces without changing its public API or intended behavior.
Microsoft.Data.SqlClient.Parser.Parser.LoginandParser.Tokens.This is layer 1 of 3 in the TDS parser organization stack and targets
main.Issues
Supersedes closed PR #4675. No linked issue; this is an internal code-organization refactor.
Testing
Existing functional, manual, and unit test sources are updated to use the reorganized parser namespaces. No new test run was performed during PR submission.
Guidelines
Tests added or updated
Public API changes documented (not applicable; no public API change intended)
Verified against customer repro (not applicable)
Ensure no breaking changes introduced
Contributing
Code of Conduct
Best Practices
Coding Style
Review Process