Skip to content

Conversation

edwardneal
Copy link
Contributor

Description

This picks up where #3434 left off. The earlier PR handled the simple case of merging OS-specific functionality (which was actually just different between the native and managed SNIs.) This one expands the principle, moving PostReadAsyncForMars and WaitForSSLHandShakeToComplete from TdsParser to TdsParserStateObject's child classes. This removes TdsParser.Unix.cs and TdsParser.Windows.cs.

This has also involved modifying the call site for the method within TdsParser to reference TdsParserStateObject. This is particularly noticeable in EnableSsl.

Finally, while it's not a new gap, this process has highlighted that the existing functionality of warning when down-level SSL is in use only functions on Windows. I've maintained this gap and made it a little more explicit.

Issues

Contributes to #1261 and #2953.

Testing

Testing with SSL- and MARS-enabled connection strings works, I'd appreciate a CI run.

This was lingering from earlier work to change the SSPI abstractions
The managed SNI doesn't use this, so will always return SNI_SUCCESS_IO_PENDING.
The handling of this method is unusual. Only Windows actually waits for the SSL handshake.
Also mop up the unused SNIErrorDetails structure
This exposes a behavioural difference in TdsParser between Unix and Windows: downlevel TLS warnings only appear on Windows.
@edwardneal edwardneal requested a review from a team as a code owner July 9, 2025 22:58
@benrr101
Copy link
Contributor

/azp run

@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Jul 10, 2025
@benrr101 benrr101 added this to the 7.0-preview1 milestone Jul 10, 2025
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

paulmedynski
paulmedynski previously approved these changes Jul 18, 2025
@benrr101
Copy link
Contributor

@edwardneal I wanted to resolve the conflicts for you, but there's one with TdsParserStateObject.PostReadAsyncForMars that I'm not sure the right way to resolve. Seems to me we shouldn't be checking for managed SNI in the native state object, but I'm not an expert here.

I'll give the overall change a review, but let me know when the conflict is resolved and we can get a CI run going.

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.

Just bamboozled over the empty try blocks, and curious about the SslProtocols type.

Feed the correct SslProtocols type through the SNI layers
@edwardneal
Copy link
Contributor Author

Thanks @benrr101 - I've handled the remaining code review feedback.

@benrr101
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 60.71429% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.82%. Comparing base (63443f4) to head (8bf5970).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 0.00% 8 Missing ⚠️
...osoft/Data/SqlClient/TdsParserStateObjectNative.cs 64.70% 6 Missing ⚠️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 60.00% 4 Missing ⚠️
...osoft/Data/SqlClient/TdsParserStateObjectNative.cs 92.85% 1 Missing ⚠️
...oft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs 0.00% 1 Missing ⚠️
.../SqlClient/ManagedSni/SniMarsConnection.netcore.cs 0.00% 1 Missing ⚠️
...Data/SqlClient/ManagedSni/SniMarsHandle.netcore.cs 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (63443f4) and HEAD (8bf5970). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (63443f4) HEAD (8bf5970)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3469      +/-   ##
==========================================
- Coverage   69.90%   61.82%   -8.08%     
==========================================
  Files         276      268       -8     
  Lines       62414    62148     -266     
==========================================
- Hits        43629    38423    -5206     
- Misses      18785    23725    +4940     
Flag Coverage Δ
addons ?
netcore 67.27% <61.76%> (-5.56%) ⬇️
netfx 60.92% <59.09%> (-8.71%) ⬇️

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 merged commit f4c8561 into dotnet:main Aug 7, 2025
237 checks passed
@edwardneal edwardneal deleted the merge/tdsparser-partial-methods branch August 7, 2025 11:49
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.

3 participants