Merge common code bases for TdsParserStateObject.cs (5) #2302
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.
This is a draft PR as I intend to add a few more commits. But let me know if you think this should be merged by itself.
So, in this comment, I asked about ValidateSNIConnection (3rd question, 4 possible solutions are suggested). @David-Engel responded and it looks like we both agree on the implementation of this PR.
To sum up, this PR effectively changes the implementation of IsConnectionAlive in netfx to check if the handle is null before passing it to SNICheckConnection. If it is null, the connection will be considered alive. This behavior is in line with netcore implementation for native.
Moreover, it appears that:
Therefore, an even better implementation would be to throw an exception (or at least use a debug assertion) to make sure the handle is never null when CheckConnection is called. Note that netcore already does this for the managed implementation (which reinforces the assumption (3)). The null check below the linked line is redundant by the way (I guess the null check predated throwing the exception).
Let me know what you think @Wraith2 @DavoudEshtehari @JRahnama @David-Engel