An async-iterator method is replaced by a kick-off method, which initializes a state machine. It does not start running the state machine (unlike kick-off methods for regular async method).
The kick-off method method is marked with both `AsyncStateMachineAttribute` and `IteratorStateMachineAttribute`.
The state machine for an async-iterator method primarily implements `IAsyncEnumerable<T>` and `IAsyncEnumerator<T>`.
It is similar to a state machine produced for an async method. It contains builder and awaiter fields, used to run the state machine in the background (when an `await` is reached in the async-iterator).
It is similar to a state machine produced for an async method. It contains builder and awaiter fields, used to run the state machine in the background (when an `await` is reached in the async-iterator). It also captures parameter values (if any) or `this` (if needed).
But it contains additional state:
- a promise of a value-or-end,
- a `bool` flag indicating whether the promise is active or not,
- a current yielded value of type `T`.
The central method of the state machine is `MoveNext()`. It gets run by `WaitForNextAsync()` and `TryGetNext()`, or as a background continuation initiated from these from an `await` in the method.
The promise of a value-or-end is returned from `WaitForNextAsync`. It can be fulfilled with either:
-`true` (when a value becomes available following background execution of the state machine),
@@ -701,7 +701,7 @@ internal class CSharpResources {
}
/// <summary>
/// Looks up a localized string similar to Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'.
/// Looks up a localized string similar to Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'.
@@ -710,7 +710,7 @@ internal class CSharpResources {
}
/// <summary>
/// Looks up a localized string similar to Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?.
/// Looks up a localized string similar to Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?.
<value>foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach await'?</value>
<value>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</value>
<value>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</value>
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem;
usingMicrosoft.CodeAnalysis.CSharp.Symbols;
usingRoslyn.Utilities;
namespaceMicrosoft.CodeAnalysis.CSharp
...
...
@@ -114,8 +113,8 @@ public override int GetHashCode()
// Produce the implementation for `T TryGetNext(out bool success)`:
// if (this._promiseIsActive)
// {
// if (_valueOrEndPromise.GetStatus(_valueOrEndPromise.Version) == ValueTaskSourceStatus.Pending) throw new Exception(); // PROTOTYPE(NullableReferenceTypes): Add this safeguard code
// if (_valueOrEndPromise.GetStatus(_valueOrEndPromise.Version) == ValueTaskSourceStatus.Pending) throw new Exception(); // https://github.com/dotnet/roslyn/issues/30109 Add this safeguard code
// if (_valueOrEndPromise.GetStatus(_valueOrEndPromise.Version) == ValueTaskSourceStatus.Pending) throw new Exception();
// if (State == StateMachineStates.NotStartedStateMachine) throw new Exception("You should call WaitForNextAsync first"); // PROTOTYPE(NullableReferenceTypes): Add this safeguard code
// if (State == StateMachineStates.NotStartedStateMachine) throw new Exception("You should call WaitForNextAsync first"); // https://github.com/dotnet/roslyn/issues/30109 Add this safeguard code
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8813,8 +8818,8 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8826,8 +8831,8 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8800,8 +8805,8 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8801,8 +8806,8 @@ Pour supprimer l'avertissement, vous pouvez utiliser la commande /reference (dé
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8802,8 +8807,8 @@ Per rimuovere l'avviso, è invece possibile usare /reference (impostare la propr
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note/>
</trans-unit>
<trans-unitid="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<targetstate="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note/>
</trans-unit>
<trans-unitid="ERR_CantUseInOrOutInArglist">
...
...
@@ -8826,8 +8831,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<note/>
</trans-unit>
<trans-unitid="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note/>
</trans-unit>
<trans-unitid="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<targetstate="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note/>
</trans-unit>
<trans-unitid="ERR_CantUseInOrOutInArglist">
...
...
@@ -8826,8 +8831,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<note/>
</trans-unit>
<trans-unitid="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8805,8 +8810,8 @@ Aby usunąć ostrzeżenie, możesz zamiast tego użyć opcji /reference (ustaw w
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8806,8 +8811,8 @@ Para incorporar informações de tipo de interoperabilidade para os dois assembl
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8808,8 +8813,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note />
</trans-unit>
<trans-unit id="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<target state="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note />
</trans-unit>
<trans-unit id="ERR_CantUseInOrOutInArglist">
...
...
@@ -8814,8 +8819,8 @@ Uyarıyı kaldırmak için, /reference kullanabilirsiniz (Birlikte Çalışma T
<note />
</trans-unit>
<trans-unit id="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<target state="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note/>
</trans-unit>
<trans-unitid="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<targetstate="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note/>
</trans-unit>
<trans-unitid="ERR_CantUseInOrOutInArglist">
...
...
@@ -8826,8 +8831,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<note/>
</trans-unit>
<trans-unitid="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'. Did you mean 'foreach' rather than 'foreach await'?</target>
<note/>
</trans-unit>
<trans-unitid="ERR_BadDynamicAsyncForEach">
<source>Cannot use a collection of dynamic type in an asynchronous foreach</source>
<targetstate="new">Cannot use a collection of dynamic type in an asynchronous foreach</target>
<note/>
</trans-unit>
<trans-unitid="ERR_CantUseInOrOutInArglist">
...
...
@@ -8826,8 +8831,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<note/>
</trans-unit>
<trans-unitid="ERR_AsyncForEachMissingMember">
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public definition for '{1}'</target>
<source>Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</source>
<targetstate="new">Async foreach statement cannot operate on variables of type '{0}' because '{0}' does not contain a public instance definition for '{1}'</target>
// (6,33): error CS9001: Async foreach statement cannot operate on variables of type 'C' because 'C' does not contain a public definition for 'GetAsyncEnumerator'
// (6,33): error CS9001: Async foreach statement cannot operate on variables of type 'C' because 'C' does not contain a public instance definition for 'GetAsyncEnumerator'
// (6,33): error CS9001: Async foreach statement cannot operate on variables of type 'C' because 'C' does not contain a public definition for 'GetAsyncEnumerator'
// (6,33): error CS9001: Async foreach statement cannot operate on variables of type 'C' because 'C' does not contain a public instance definition for 'GetAsyncEnumerator'
// (7,33): error CS9005: Async foreach statement cannot operate on variables of type 'IEnumerable<int>' because 'IEnumerable<int>' does not contain a public definition for 'GetAsyncEnumerator'. Did you mean 'foreach' rather than 'foreach await'?
// (7,33): error CS9005: Async foreach statement cannot operate on variables of type 'IEnumerable<int>' because 'IEnumerable<int>' does not contain a public instance definition for 'GetAsyncEnumerator'. Did you mean 'foreach' rather than 'foreach await'?
// (7,17): error CS4033: The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
// (6,33): error CS9005: Async foreach statement cannot operate on variables of type 'C' because 'C' does not contain a public definition for 'GetAsyncEnumerator'. Did you mean 'foreach' rather than 'foreach await'?
// (6,33): error CS9005: Async foreach statement cannot operate on variables of type 'C' because 'C' does not contain a public instance definition for 'GetAsyncEnumerator'. Did you mean 'foreach' rather than 'foreach await'?
// (6,33): error CS9001: Async foreach statement cannot operate on variables of type 'D' because 'D' does not contain a public definition for 'GetAsyncEnumerator'
// (6,33): error CS9002: Async foreach requires that the return type 'D.Enumerator' of 'D.GetAsyncEnumerator()' must have suitable public WaitForNextAsync and TryGetNext methods
// (6,33): error CS9002: Async foreach requires that the return type 'D.Enumerator' of 'D.GetAsyncEnumerator()' must have suitable public WaitForNextAsync and TryGetNext methods
// PROTOTYPE(async-streams) test ForEachStatementInfo equality and such
}
// PROTOTYPE(async-streams) More test ideas
// block dynamic
// test with captures:
// int[] values = { 7, 9, 13 };
...
...
@@ -3415,10 +3749,7 @@ public void TestFoEachStatementInfo_IEquatable()
//}
// f();
// pointer element type
// verify that the foreach variables are readonly
// nested deconstruction or tuple
// pattern with inaccessible methods
// review instrumentation
// test various things that could go wrong with binding the await for DisposeAsync
// throwing exception from enumerator, or from inside the async-foreach
...
...
@@ -3428,15 +3759,10 @@ public void TestFoEachStatementInfo_IEquatable()
// IOperation
// IDE
// scripting?
// foreach on restricted type (like ref struct) in async or iterator method
// foreach on restricted type in a regular method
// Also try with ref-returning TryGetNext. With both ref iteration variable and ordinary one. Not sure what spec says here, but technically either could work. Especially the ordinary byval case - it could even do implicit conversions. Ref-returning methods can work as rvalues too.
// Also, if ref iteration variables are allowed, check readonliness mismatches. I.E. if method returns a readonly ref, but iterator var is an ordinary ref nd the other way around.
// expression trees
// Misc other test ideas:
// Verify that async-dispose doesn't have a similar bug with struct resource
// cleanup: use statement lists for async-using, instead of blocks
// IAsyncEnumerable has an 'out' type parameter, any tests I need to do related to that?
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.