-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge common code bases for TdsParserStateObject.cs (2) #1844
Conversation
…arts of dotnet#285 to netfx).
…ged behavior of CheckConnection for netfx, to make it same as netcore, affecting IsConnectionAlive).
…ds of TdsParserStateObject.
…ds of TdsParserStateObject.
internal partial class TdsParserStateObject | ||
{ | ||
private static bool UseManagedSNI => false; | ||
|
||
private SNIHandle _sessionHandle = null; // the SNI handle we're to work on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should'nt this be removed to be replase by SessionHandle struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to replace SNIHandle with SessionHandle struct at line 32?
If yes, you can't do this because I have defined it as readonly ref
. I needed to "add" the IsNull property to SNIHandle, so I encapsulated it in a struct. Then I added readonly ref
so that this struct never allocates memory and is copied as if it was a plain reference. This is an optimization which is probably not needed, but I tried to make as little behavioral/performance changes as possible while refactoring.
Edit: to clarify, SessionHandle struct is only created and used in certain methods. There is a readonly ref
SessionHandle in netcore version used in a similar way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see. I was asking myself about encapsulating like in netcore version that why I have read it too fast. Thanks for clarification
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1844 +/- ##
==========================================
+ Coverage 70.82% 73.40% +2.57%
==========================================
Files 292 224 -68
Lines 61777 36213 -25564
==========================================
- Hits 43752 26581 -17171
+ Misses 18025 9632 -8393
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Thanks @panoskj for making each method merge as a separate commit so it's easier to review especially when working with a fairly large file :) |
@lcheunglci I'm glad you find smaller commits useful. It should be mentioned that I wrote this code 7-8 months ago and now rebased it on the latest version. But meanwhile, I added some style changes in #1520. As a result, some of these style changes are missing in the merged file of this PR. It may look like a regression, but I intend to add another commit that brings them back again. |
…Removed unnecessary casts. Removed unnecessary assignment. Added readonly specifier where possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some quick change without changing behavior
private SessionHandle SessionHandle => new SessionHandle(_sessionHandle); | ||
|
||
private bool TransparentNetworkIPResolution => _parser.Connection.ConnectionOptions.TransparentNetworkIPResolution; | ||
|
||
internal bool _pendingData = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make private this field and use HasPendingData property where it's not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields are used across many files, that's why I didn't touch them. But I now see they will help with merging TdsParser, so I will add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that was my point to change them and it's a quick harmless refactoring. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added a commit implementing the requested change.
private SessionHandle SessionHandle => new SessionHandle(_sessionHandle); | ||
|
||
private bool TransparentNetworkIPResolution => _parser.Connection.ConnectionOptions.TransparentNetworkIPResolution; | ||
|
||
internal bool _pendingData = false; | ||
internal bool _errorTokenReceived = false; // Keep track of whether an error was received for the result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make private this field and add the same property with get/set on it as NetCore:
internal bool HasReceivedError
{
get => _errorTokenReceived;
set => _errorTokenReceived= value;
}
@@ -35,12 +50,6 @@ internal partial class TdsParserStateObject | |||
// Timeout variables | |||
internal bool _attentionReceived = false; // NOTE: Received is not volatile as it is only ever accessed\modified by TryRun its callees (i.e. single threaded access) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make private this field and add the same property with get/set on it as NetCore:
internal bool HasReceivedAttention
{
get => _attentionReceived;
set => _attentionReceived= value;
}
// the code but does not remember either. At some point, we need to research killing this | ||
// logic. | ||
private volatile int _allowObjectID; | ||
|
||
internal bool _hasOpenResult = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make private this field and use HasOpenResult property where it's not used
@@ -51,45 +60,6 @@ internal partial class TdsParserStateObject | |||
|
|||
internal bool _receivedColMetaData; // Used to keep track of when to fire StatementCompleted event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make private this field and add the same property with get/set on it as NetCore:
internal bool HasReceivedColumnMetadata
{
get => _receivedColMetaData;
set => _receivedColMetaData= value;
}
…expose the same interface as netcore version. This helps merging other files, such as TdsParser.
…ry assignments. Used discard to ignore out parameters, instead of an unused variable.
Please review this commit with special care. It may change the behavior of IsConnectionAlive method in some edge case for netfx (so that netfx behavior matches netcore). To me it looks like either the netcore version is correct, or both versions are correct (and their behavior is actually the same). PS: we would have to look into the native driver's code to determine whether the behavior changed or not, that's why I am unsure. The method in question is SNINativeMethodWrapper.SNICheckConnection, specifically in the case it receives a null value. |
Any news on merging this @lcheunglci |
Yes, we'll get to reviewing it after the 5.1.0 release. |
…rStateObject-2 # Conflicts: # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs
Can we get an update on this please? there's still a lot of work to be done with merges and this has been open a long time now. |
/azurepipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
If this is too big or too old a changeset to be reviewed and merged it could be closed and individual pieces of the work re-done in smaller PR's. |
I totally agree with you. Let's break this down in several PRs and merge them before the next preview release. On some other notes, I was considering, just me this is not a team decision or official roadmap, converting the netfx to SDK style project and do some testing for code base merging. That would make our lives a lot easier I think. It would probably will give us a bit more complicated csproj, but one csproj which works for all of them. |
@panoskj will you be able to break this PR to couple of smaller changeset or you prefer someone else to do it? |
On the "breaking it up" suggestion. Troubleshooting the pipeline failures might be easier by breaking it up, too. I'd first try to make changes to the separate TdsParserStateObject.cs files to bring them closer to identical. Ideas for steps in individual PRs:
|
@JRahnama @Wraith2 I will be able to split the PR within the next 4 weeks - my free time is very limited right now. Luckily, most commits are independent, so it should be easy to split the PR. The reason I made it so large, is because I thought it would take you even more time, in total, to review 10 PRs, judging from the time it took you to accept the previous, smaller PR. Also keep in mind this file has several more thousands of lines to be merged once this PR is accepted. |
Second part of #1520. As I explained in this comment, #1843 does more or less the same, but I have already written the code for this PR. Perhaps you will find some use for it.
As for the code itself, you will notice I have left lots of #if directives, intentionally, to highlight the differences between the two versions, before deciding how to resolve them.
PS: either way, please try to merge one of these PRs as soon as possible. They will allow us to partially fix the async bug. A full fix would require
SqlDataReaderTdsParser too, if I remember correctly.