You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"missing ManualResetValueTaskSourceLogic":
The preview1 compiler is looking for that type, but .NET Core 3 preview 1 contains ManualResetValueTaskSourceCore. The solution is to include this code snippet in your program. This will be fixed in preview2.
Test with ConvertForeachToFor refactoring (verified manually, not triggered)
LDM open issues:
async LINQ
Parsing issue with return from e in async-collection select await e + 1; // await isn't a keyword
how does above scenario and return from e in async-collection select e + 1; lower into LINQ APIs? (the one with await involves Task<int> and the other one involves int directly) How many overloads of Select do we need?
Should there be some helper method to convert from IEnumerable to IAsyncEnumerable, or from Task to IAsyncEnumerable?
Should the generate token checks be in GetAsyncEnumerator or in MoveNextAsync? (if we do, we need to store the token and maybe dispose it too) (answer: no)
Revisit blocking off a word (either in parameter list, like params, or for variable name, like value) for token (answer: we're not going to use a keyword)
pattern-based await using should recognize a DisposeAsync method that returns a task-like (or only ValueTask)? (not applicable because no ref structs in async methods)
What attributes should be emitted on async-iterator state machines? (answer: AsyncIteratorStateMachineAttribute)
cancellation of async-streams (both as consumer and producer) (see LDM 11/28)
confirm syntax for async foreach
Should we disallow struct async enumerator? (no, same as regular async, see TestWithPattern_WithStruct_MoveNextAsyncReturnsTask)
Should DisposeAsync return a non-generic ValueTask, since there is now one? Or stick with Task?
Extension methods for GetAsyncEnumerator, WaitForNextAsync, and TryGetNext do not contribute. This mirrors behavior for regular foreach. But I'd like to confirm. (answer: this is probably something we want to support. Let's queue that for later in the implementation)
Should the pattern for async enumerators also recognize when a task-like is returned instead of Task<bool>? (answer: yes)
I think we'll need to block dynamic since there is no async counterpart to the non-generic IEnumerable that would convert dynamic to. (answer: seems ok)
Do we need async keyword on async iterator methods? I assume yes.
Since not enumerable lambdas, I assume the same for async-enumerable. (answer: correct. No async iterator lambda)
async-iterator without yield or await, should warn? (answer: without yield it's not recognized as an iterator, warn when no await)
I suspect we'll need to declare the loop variable differently: calling TryGetNext first, then checking success and only then dealing with conversions and deconstructions.
Spec: https://github.com/dotnet/csharplang/blob/master/proposals/csharp-8.0/async-streams.md
Championed issue: dotnet/csharplang#43
Notes on cancellation token and
[EnumeratorCancellation]: http://blog.monstuff.com/archives/2019/03/async-enumerables-with-cancellation.htmlFAQ and known issues
The preview1 compiler is looking for that type, but .NET Core 3 preview 1 contains
ManualResetValueTaskSourceCore. The solution is to include this code snippet in your program. This will be fixed in preview2.yield returnin construct withfinally) (see issue Async-Streams: iteration stops early on Core #31268)NullableReferenceTypesproject property doesn't take full effect in legacy projects yet (Add support for Nullable build setting project-system#4058)Async-iterator methods
blockusingdeclarations, including asynchronous ones #32589 forawait usingdeclarations)yield returnwhen directly following anotheryield return(to reduce cost inManualResetValueTaskSourceCore.SetResult) (issue Async-streams: Consider optimizing handling of yield directly following yield #31248, needs LDM)GetStatusandOnCompletedfor implementingIValueTaskSourceandIValueTaskSource<bool>Async-streams: consider factoring IValueTaskSource implementation methods #31517goto,continue,breakasyncAsync-streams: improve diagnostic when missingasynckeyword #31113IAsyncEnumerable<T>andIAsyncEnumerator<T>.factor some code into a base type?(no)introduce new exception type?(not needed at the moment)EnumeratorCancellationissue Support forEnumeratorCancellationAttribute(C# 8.0) mono/mono#14454)DisposeAsync(): if state is-1, then throw. PR Add guard to DisposeAsync #31764MoveNextAsync()if possible (issue Async-streams: Consider optimizing return logic ofMoveNextAsync()#31246, PR Async-streams: Optimize return of MoveNextAsync #31645)GetAsyncEnumeratorAPI (PR Async-streams: Add CancellationToken to GetAsyncEnumerator #31624)finallyissue DisposeAsync of async-iterator method should execute requiredfinallyblocks #30260, PR Async-streams: Disposal in async-iterator methods #31527DisposeAsync(). it is ok to dispose before enumerating, and then you start enumerating?AsyncIteratorStateMachineAttributePR Async-streams: Emit AsyncIteratorStateMachine attribute on async-iterator methods #31553AwaitOnCompletedinstead ofAwaitUnsafeOnCompletedAsyncIteratorMethodBuilder,ManualResetValueTaskSourceCore, removeIStrongBox<T>) PR Async-streams: use ManualResetValueTaskSourceCore and AsyncIteratorMethodBuilder types #31330IAsyncEnumerator<T>Async-streams: Add support for enumerator-returning async-iterator method #31057, PR Async-iterator method can returnIAsyncEnumerator<T>#31114threadIDdesign (see https://github.com/dotnet/corefx/issues/3481)GetAsyncEnumerator()method should make a new instance in some cases Async-Streams: GetAsyncEnumerator should produce new instances when needed #30275, PR Allow multiple calls to GetAsyncEnumerator #31105IOperationandCFGshould not crash Async-streams: minimal test for IOperation and CFG. Improve diagnostics #30363IAsyncEnumerableAPI Update IAsyncEnumerator API #30280Async using and foreach
ref structenumerator #32794)Disposeextension methods should not even be considered in pattern-based disposal #32767)await foreachto use extension methods #32289)ERR_AwaitForEachMissingMemberWrongAsyncGetAwaitExpressionInfoSatisfiesForEachPattern(special method of looking upCurrent)IEnumerable<T>andIAsyncEnumerable<T>.IDisposableandIAsyncDisposable.await foreachandawait using(issue Async-streams:await foreachdoesn't dispose result fromConfigureAwait#32316)ConfigureAwait/WithCancellationnot recognized byawait foreach(issueConfiguredAsyncEnumerablein netcoreapp3.0 preview is not acceptable with await foreach (CS8142)? #31609, PR Async-streams: Recognize MoveNextAsync that returns an awaitable #32233)CancellationToken(issue Adjust pattern-based lookup forawait foreach#32111, PR Pattern-based 'await foreach' should find parameterless 'GetAsyncEnumerator' and 'MoveNextAsync' #32184)IOperationandCFGshould not crash Async-streams: minimal test for IOperation and CFG. Improve diagnostics #30363await usingandawait foreachsyntax Async-streams: Update syntax to 'await using' and 'await foreach' #30525IAsyncEnumerableAPI Update IAsyncEnumerator API #30280Only convert/deconstruct whenTryGetNextsucceeded Convert/deconstruct in async-foreach only if TryGetNext succeeded #30258IAsyncEnumerator.WaitForNextAsyncto return aValueTask<bool>.WaitForNextAsyncforeach await (ref x in ...) ...(error,TestWithPattern_Ref)WaitForNextAsyncthat returns a task-like.Productivity (code fixers/refactorings/etc):
ExtractMethod doesn't work on parts of or entire async-iterator method body(that's expected)Disposereferenced inusingandforeachstatements #28228)GetAwaiterfrom an async-foreach or async-dispose.DisposeAsyncfrom an async-foreach or async-dispose.AsyncDisposemethoddecompilation feature in IDE(we'll let ILSpy library fix this)foreach(by adding/removingawait) depending on the collection type. (PR Add MakeStatementAsynchronous fixer #33463)using(by adding/removingawait) depending on resource type. (PR Add MakeStatementAsynchronous fixer #33463)yieldorawait(MakeMethodAsync PR MakeMethodAsync: fix iterator methods #31846)foreach awaitin non-async method should offer to convert the method toasyncAdding some IDE code fix tests for async using & foreach #26632await usingandawait foreach. For instance, seeIsLocalVariableDeclarationContext.asyncandawait(see Fixing async keyword highlighting on local functions #25037, PR Adding await keyword highlighting on async using & foreach #25056) (verified manually on method and local function)ConvertForeachToForrefactoring (verified manually, not triggered)LDM open issues:
return from e in async-collection select await e + 1; // await isn't a keywordreturn from e in async-collection select e + 1;lower into LINQ APIs? (the one withawaitinvolvesTask<int>and the other one involvesintdirectly) How many overloads ofSelectdo we need?GetAsyncEnumeratoror inMoveNextAsync? (if we do, we need to store the token and maybe dispose it too) (answer: no)params, or for variable name, likevalue) for token (answer: we're not going to use a keyword)await usingshould recognize aDisposeAsyncmethod that returns a task-like (or onlyValueTask)? (not applicable because no ref structs in async methods)foreachrecognize... GetAsyncEnumerator()(withoutCancellationToken)? (yes, LDM 1/9)AsyncIteratorStateMachineAttribute)structasync enumerator? (no, same as regular async, seeTestWithPattern_WithStruct_MoveNextAsyncReturnsTask)DisposeAsyncreturn a non-genericValueTask, since there is now one? Or stick withTask?GetAsyncEnumerator,WaitForNextAsync, andTryGetNextdo not contribute. This mirrors behavior for regularforeach. But I'd like to confirm. (answer: this is probably something we want to support. Let's queue that for later in the implementation)Task<bool>? (answer: yes)dynamicsince there is no async counterpart to the non-genericIEnumerablethat would convertdynamicto. (answer: seems ok)asynckeyword on async iterator methods? I assume yes.yieldorawait, should warn? (answer: withoutyieldit's not recognized as an iterator, warn when noawait)TryGetNextfirst, then checkingsuccessand only then dealing with conversions and deconstructions.Championed issue: dotnet/csharplang#43 (includes LDM notes)
Test ideas for async foreach:
Test ideas for async using:
Test ideas for async iterators:
GetIteratorElementTypewithIsDirectlyInIteratorthat relates to speculation, needs testingBindYieldBreakStatement); same for yield return (seeBindYieldReturnStatement)BindYieldReturnStatement) validates escape rules, needs testingIAsyncEnumerable<dynamic>dynamic?AwaitOnCompletedandAwaitUnsafeOnCompletedasync IAsyncEnumerable<int> M() { return TaskLike(); }IAsyncEnumerable<T>special from the start? Making mark it with an attribute like we did for task-like?BCL (Core)
DefaultCancellationAttributetype: https://github.com/dotnet/corefx/issues/37012PRs Add initial async iterators support to System.Private.CoreLib coreclr#20442 and Expose async iterator-related types corefx#33104
GetAsyncEnumeratorAPIWithCancellation(...)to callGetAsyncEnumeratorand wrap the result into anIAsyncEnumerableCancellationTokentoGetAsyncEnumerator()PR Add CancellationToken parameter to GetAsyncEnumerator coreclr#21397, documentation https://github.com/dotnet/corefx/issues/33338#issuecomment-444728011WithCancellationdesign https://github.com/dotnet/corefx/issues/33909IAsyncDisposable.ConfigureAwait(PRs Implement IAsyncDisposable.ConfigureAwait coreclr#22160 and Expose/test IAsyncDisposable.ConfigureAwait corefx#34783)BCL (mono)
BCL (package)
EnumeratorCancellationAttribute(PR Add [EnumeratorCancellation] to Microsoft.Bcl.AsyncInterfaces corefx#37719)References: