Fix async iterators to clear out state upon completion (#43522)
authorStephen Toub <stoub@microsoft.com>
Sun, 18 Oct 2020 23:10:32 +0000 (19:10 -0400)
committerGitHub <noreply@github.com>
Sun, 18 Oct 2020 23:10:32 +0000 (19:10 -0400)
commitc0669313dd36189c6d3bf5c7d5e866284f98263c
treea0f7777e4da672add0bba6fddf38bfde7371c055
parentda8cf83e8a8b88c0d91d6d0a46837931d0730d11
Fix async iterators to clear out state upon completion (#43522)

AsyncIteratorMethodBuilder was only doing its clean-up for completion (e.g. zeroing out the state machine and context, removing the object from a debugger-incited tracking table) if the last call to the iterator was part of asynchronous completion; if the last MoveNextAsync completed synchronously, the used code path could miss that cleanup work.
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncIteratorMethodBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilderT.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IAsyncStateMachineBox.cs
src/libraries/System.Threading.Tasks/tests/System.Runtime.CompilerServices/AsyncIteratorMethodBuilderTests.cs [new file with mode: 0644]
src/libraries/System.Threading.Tasks/tests/System.Threading.Tasks.Tests.csproj