Skip to content

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented Nov 18, 2025

Relates to test plan #75960

@jcouv jcouv self-assigned this Nov 18, 2025
@jcouv jcouv force-pushed the async-iterator2 branch 4 times, most recently from 2765f0d to 8542bed Compare November 24, 2025 23:33
The `GetAsyncEnumerator` method either returns the current instance if it can be reused,
or creates a new instance of the state machine class.

Assuming that the unspeakble state machine class is named `Unspeakable`, `GetAsyncEnumerator` is emitted as:
Copy link
Member

@stephentoub stephentoub Nov 26, 2025

Choose a reason for hiding this comment

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

Nit:

Suggested change
Assuming that the unspeakble state machine class is named `Unspeakable`, `GetAsyncEnumerator` is emitted as:
Assuming that the unspeakable state machine class is named `Unspeakable`, `GetAsyncEnumerator` is emitted as:
``` #Resolved


#### Lowering of `yield return`

`yield return` is disallowed in finally, in try with catch and in catch.
Copy link
Member

@stephentoub stephentoub Nov 26, 2025

Choose a reason for hiding this comment

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

Unrelated to this PR, we were going to look at removing some of these restrictions, in particular for yields inside of a try with a catch, right? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there's a proposal for that, tracked independently: dotnet/csharplang#8414
It's not clear whether this would make it into C# 15 yet


## Open issues

Question: AsyncIteratorStateMachineAttribute, or IteratorStateMachineAttribute, or other attribute on kickoff method?
Copy link
Member

@stephentoub stephentoub Nov 26, 2025

Choose a reason for hiding this comment

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

Why would this need to differ from what we do today? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure yet. We introduced a different attribute for each state machine design so far.
Edit&Continue looks at this attribute and also relies on Symreader which also looks at the attribute. Symreader uses it to find the MoveNext method, but here the naming convention is different (it's "MoveNextAsync").
I didn't investigate the debug symbols or EnC yet. Need to talk to Tomas ;-)

@jcouv jcouv marked this pull request as ready for review December 1, 2025 17:08
@jcouv jcouv requested a review from a team as a code owner December 1, 2025 17:08
@jcouv jcouv mentioned this pull request Dec 1, 2025
40 tasks
Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Done review pass (commit 1). Tests are not looked at yet.


Async methods that return `IAsyncEnumerable<T>` or `IAsyncEnumerator<T>` are transformed by the compiler into state machines.
States are created for each `await` and `yield`.
Runtime-async support was added in .NET 10 as a preview feature and reduces the overhead of async methods by letting the runtime handling `await` suspensions.
Copy link
Member

@jjonescz jjonescz Dec 2, 2025

Choose a reason for hiding this comment

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

Suggested change
Runtime-async support was added in .NET 10 as a preview feature and reduces the overhead of async methods by letting the runtime handling `await` suspensions.
Runtime-async support was added in .NET 10 as a preview feature and reduces the overhead of async methods by letting the runtime handle `await` suspensions.
``` #Resolved

@jcouv jcouv requested a review from 333fred December 3, 2025 21:47
Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Mostly LGTM. Just a couple of small comments.

@jcouv jcouv requested a review from RikkiGibson December 4, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants