dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
706 stars 1.55k forks source link

TaskCompletionSource TrySetResult incorrectly states it will return false is the Task is disposed #8108

Open PaintThis opened 2 years ago

PaintThis commented 2 years ago

The below line also contradicts that it will actually throw a DisposedException if the Task is disposed.

This method also returns false if the underlying <xref:System.Threading.Tasks.Task%601> has already been disposed.

Checking this, seems to verify that it will throw instead of returning false: https://referencesource.microsoft.com/#mscorlib/system/threading/Tasks/TaskCompletionSource.cs

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/area-system-threading-tasks See info in area-owners.md if you want to be subscribed.

Issue Details
The below line also contradicts that it will actually throw a DisposedException if the Task is disposed. This method also returns false if the underlying has already been disposed. Checking this, seems to verify that it will throw instead of returning false: https://referencesource.microsoft.com/#mscorlib/system/threading/Tasks/TaskCompletionSource.cs
Author: PaintThis
Assignees: -
Labels: `untriaged`, `Pri3`, `area-System.Threading.Tasks`
Milestone: -
stephentoub commented 2 years ago

It is correct that TrySetResult will return false if the Task was disposed. (This falls out from the fact that you can only call Dispose on a task that has already completed, and TrySetResult will return false if the task has already completed).

It is incorrect that TrySetResult will throw if the Task was disposed. That Exceptions portion of the docs should be stricken.

buyaa-n commented 2 years ago

The source doc looks correct, seems the doc repo kept old doc from .Net framework source. https://github.com/dotnet/runtime/blob/3439e2ce9b2dbb7649b44136de7ddad140471289/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCompletionSource.cs#L204-L214

@carlossanlop is there a tool I can use to update / sync source doc with doc repo, I know you run a tool each release, but seems that is apply/work only for new APIs

carlossanlop commented 2 years ago

but seems that is apply/work only for new APIs

That is correct, the tool only ports new documentation from triple slash to dotnet-api-docs. It won't overwrite anything in dotnet-api-docs.

Updates to existing docs need to be made manually.