Skip to content

Enable CA2012 (Use ValueTasks correctly)#54697

Merged
sharwell merged 2 commits intodotnet:mainfrom
sharwell:valuetasks
Jul 13, 2021
Merged

Enable CA2012 (Use ValueTasks correctly)#54697
sharwell merged 2 commits intodotnet:mainfrom
sharwell:valuetasks

Conversation

@sharwell
Copy link
Copy Markdown
Contributor

@sharwell sharwell commented Jul 8, 2021

No description provided.

@sharwell sharwell requested review from a team as code owners July 8, 2021 22:49
@ghost ghost added the Area-IDE label Jul 8, 2021
if (isEnabledValueTask.IsCompleted)
return isEnabledValueTask.Result;

isEnabledValueTask.Preserve();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ValueTask backed by constants or Task, nothing. But for ones backed by IValueTaskSource (which can pool), registers a continuation that calls GetResult to return the source lease.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Changed the code to use Forget instead of Preserve, plus the commit links to microsoft/vs-threading#556.

@sharwell sharwell enabled auto-merge July 10, 2021 07:06
@davidwengier davidwengier disabled auto-merge July 10, 2021 22:23
@davidwengier davidwengier enabled auto-merge (squash) July 10, 2021 22:23
@davidwengier
Copy link
Copy Markdown
Member

Oops, sorry. That button is easy to hit accidentally in the GitHub iOS app!

@sharwell sharwell disabled auto-merge July 11, 2021 00:54
@sharwell sharwell enabled auto-merge July 11, 2021 00:54
@sharwell sharwell merged commit 6e5cf07 into dotnet:main Jul 13, 2021
@ghost ghost added this to the Next milestone Jul 13, 2021
@allisonchou allisonchou modified the milestones: Next, 17.0.P3 Jul 27, 2021
@sharwell sharwell deleted the valuetasks branch January 13, 2022 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants