You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor TDS parser into focused namespaces and files - #4675
Refactors the TDS parser implementation into focused files and namespaces without changing its public API or intended behavior.
Splits helper types, enums, safe handles, parser state, and related classes out of the large legacy source files.
Moves parser implementation types under Microsoft.Data.SqlClient.Parser.
Groups login and token-related types under Parser.Login and Parser.Tokens.
Preserves file history through step-wise moves so reviewers can distinguish relocation from structural cleanup.
Updates internal references and affected tests for the new namespaces.
This is layer 1 of 3 in the TDS parser organization stack and targets main.
Issues
No linked issue; this is an internal code-organization refactor.
Testing
No behavior change is intended. Existing functional and unit test sources were updated to use the reorganized parser namespaces; CI will exercise the supported target frameworks and platforms.
This namespace move leaves reflection consumers pointing at Microsoft.Data.SqlClient.TdsParser: ConnectionHelper.cs:52 and TdsParserHelper.cs:13 now receive null from Assembly.GetType (the former dereferences it during static initialization), and the stress-test filter at FilteredDefaultTraceListener.cs:84 no longer matches the new stack-frame name. Update those strings to Microsoft.Data.SqlClient.Parser.TdsParser as part of this move. src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObject.cs:28
Several reflection-based tests still request Microsoft.Data.SqlClient.TdsParserStateObject (ConnectionHelper.cs:57, TdsParserStateObjectHelper.cs:27, and MARSTest.cs:87/135). After this move, Assembly.GetType returns null, causing static-initializer assertion/null-reference failures; the stress filter at FilteredDefaultTraceListener.cs:85-86 also stops matching. Update all of these strings to the new Microsoft.Data.SqlClient.Parser.TdsParserStateObject name. src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObjectManaged.netcore.cs:21
TdsParserStateObjectHelper.cs:48 still reflects Microsoft.Data.SqlClient.ManagedSni.TdsParserStateObjectManaged. On .NET builds this now resolves to null; the helper treats that as framework absence and later throws when a managed session handle is requested. Update the reflected name to Microsoft.Data.SqlClient.Parser.TdsParserStateObjectManaged.
The namespace move was not propagated to reflection-based test infrastructure. tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionHelper.cs:52 and TdsParserHelper.cs:13 still request Microsoft.Data.SqlClient.TdsParser; Assembly.GetType now returns null and their static field initialization dereferences it. Update those type-name strings to Microsoft.Data.SqlClient.Parser.TdsParser; the stress-test frame filter at FilteredDefaultTraceListener.cs:84 also needs the new prefix. src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObject.cs:28
Several manual tests still resolve Microsoft.Data.SqlClient.TdsParserStateObject by name (MARSTest.cs:87,135, ConnectionHelper.cs:57, and TdsParserStateObjectHelper.cs:27). After this move those lookups return null, and the subsequent GetField calls or assertions fail. Update all reflection strings and the stress-test stack-frame entries to Microsoft.Data.SqlClient.Parser.TdsParserStateObject. src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParserStateObjectManaged.netcore.cs:21
TdsParserStateObjectHelper.cs:48 still looks up this type as Microsoft.Data.SqlClient.ManagedSni.TdsParserStateObjectManaged. The lookup now returns null, so GetSessionHandle throws “Library being tested does not implement TdsParserStateObjectManaged” for the managed implementation. Update the reflection string to Microsoft.Data.SqlClient.Parser.TdsParserStateObjectManaged.
Files reviewed: 126/126 changed files
Comments generated: 1
Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
[P2] Update the remaining reflection and stack-frame consumers of this moved type. TdsParserStateObjectHelper.cs:27,48 and MARSTest.cs:87,135 still call Assembly.GetType with the former namespaces, so they now receive null and the affected manual tests fail before exercising their scenarios. FilteredDefaultTraceListener.cs:85-86 also compares DeclaringType.FullName against the old name, so its known-assert filter no longer matches; update these strings (and the test-hook sample in this file) to Microsoft.Data.SqlClient.Parser.*.
Update TdsParser full-name consumers to the new namespace
[P2] Update consumers that still identify TdsParser by its former full name. tests/ManualTests/SQL/Common/SystemDataInternals/TdsParserHelper.cs:13 now gets null and dereferences it while initializing its field metadata, breaking every InternalConnectionWrapper.KillConnection path; FilteredDefaultTraceListener.cs:84 likewise stops recognizing the known parser assert because it compares the exact declaring-type name. Point both strings at Microsoft.Data.SqlClient.Parser.TdsParser.
Update every reflection and stack-frame consumer for this namespace move. TdsParserHelper.cs:13, TdsParserStateObjectHelper.cs:27,48, and MARSTest.cs:87,135 still request the old full names, so those manual-test paths now receive null and fail during initialization; FilteredDefaultTraceListener.cs:84-86 also stops matching the parser frames it is intended to filter. Change these strings to the corresponding Microsoft.Data.SqlClient.Parser... names.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Several reflection-based manual tests and an exact stack-frame filter still reference the former parser type names and will no longer exercise their intended scenarios.
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
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
No linked issue; this is an internal code-organization refactor.
Testing
No behavior change is intended. Existing functional and unit test sources were updated to use the reorganized parser namespaces; CI will exercise the supported target frameworks and platforms.
Guidelines