Skip to content

Change WeakReference to WeakReference<T> - #1122

Merged
cheenamalhotra merged 1 commit into
dotnet:mainfrom
Wraith2:fix-weakreference
Jun 21, 2021
Merged

cheenamalhotra merged 1 commit into
dotnet:mainfrom
Wraith2:fix-weakreference

Conversation

@Wraith2

@Wraith2 Wraith2 commented Jun 16, 2021

Copy link
Copy Markdown
Contributor

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 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
@cheenamalhotra
cheenamalhotra merged commit ddb7fc7 into dotnet:main Jun 21, 2021
@Wraith2
Wraith2 deleted the fix-weakreference branch June 21, 2021 21:00
@Dzoge

Dzoge commented Jan 4, 2022 •

Copy link
Copy Markdown

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

@Wraith2

Wraith2 commented Jan 4, 2022

Copy link
Copy Markdown
Contributor Author

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

None yet

Development

Successfully merging this pull request may close these issues.

Null Reference in GetServerTransactionLevel

4 participants