Skip to content
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

Change WeakReference to WeakReference<T> #1122

Merged
merged 1 commit into from Jun 21, 2021

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Jun 16, 2021

Reading #1121 I remembered that we're using WeakReference and not WeakReference<T>, the generic version has a different api shape using bool isAlive = TryGetTarget(out T target) to prevent the possibility of a GC between IsAlive and Target property accesses. Note that TryGetTarget returns false for null which is why some null checks are no longer needed.

@cheenamalhotra cheenamalhotra added this to In progress in SqlClient v4.0 via automation Jun 18, 2021
@cheenamalhotra cheenamalhotra added this to the 4.0.0-preview1 milestone Jun 18, 2021
@cheenamalhotra cheenamalhotra linked an issue Jun 18, 2021 that may be closed by this pull request
SqlClient v4.0 automation moved this from In progress to Reviewer approved Jun 21, 2021
@cheenamalhotra cheenamalhotra merged commit ddb7fc7 into dotnet:main Jun 21, 2021
SqlClient v4.0 automation moved this from Reviewer approved to Done Jun 21, 2021
@Wraith2 Wraith2 deleted the fix-weakreference branch June 21, 2021 21:00
@Dzoge
Copy link

Dzoge commented Jan 4, 2022

Is this issue also fixed in System.Data.SqlClient package?

@Wraith2
Copy link
Contributor Author

Wraith2 commented Jan 4, 2022

Unlikely. The System.Data.SqlClient package is deprecated in favour of this library and the only things that get back ported are security and high impact stability changes. This is simply a modernization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Null Reference in GetServerTransactionLevel
4 participants