Skip to content

Conversation

@333fred
Copy link
Member

@333fred 333fred commented Aug 19, 2025

Closes #79818.

@333fred 333fred requested review from a team as code owners August 19, 2025 21:37
@333fred
Copy link
Member Author

333fred commented Aug 19, 2025

@dotnet/roslyn-compiler for review

@dotnet-policy-service dotnet-policy-service bot added the Needs API Review Needs to be reviewed by the API review council label Aug 19, 2025
@RikkiGibson RikkiGibson self-assigned this Aug 21, 2025
@333fred 333fred merged commit 97e9ee7 into dotnet:main Aug 21, 2025
28 checks passed
@333fred 333fred deleted the await-info branch August 21, 2025 21:54
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 21, 2025
/// When runtime async is enabled for this await expression, this represents either:
/// <list type="bullet">
/// <item>
/// A call to <c>System.Runtime.CompilerServices.AsyncHelpers.Await</c>, if this is a
Copy link
Member

Choose a reason for hiding this comment

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

This is not a "call", it's a method symbol

/// </item>
/// <item>
/// A call to <c>System.Runtime.CompilerServices.AsyncHelpers.AwaitAwaiter|UnsafeAwaitAwaiter</c>.
/// In these cases, the other properties may be non-<see langword="null" /> if the
Copy link
Member

@jcouv jcouv Aug 22, 2025

Choose a reason for hiding this comment

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

I assume you mean that GetAwaiterMethod/IsCompletedProperty/GetResultMethod may be set in runtime-async scenario. Looking at the logic in GetAwaitableExpressionInfo, we don't set those in runtime-async scenario (since we won't need them). Why not make this behavior official in the public API? The behavior we have seems better than the behavior this comment describes. #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the logic in GetAwaitableExpressionInfo, we don't set those in runtime-async scenario (since we won't need them).

We do set them in this case, because we will need them.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, I misread. We don't need the other members for System.Runtime.CompilerServices.AsyncHelpers.Await case, but we do need them for the AwaitAwiter/UnsafeAwaitAwaiter cases. Thanks

GetAwaiterMethod = getAwaiter;
IsCompletedProperty = isCompleted;
GetResultMethod = getResult;
RuntimeAwaitMethod = runtimeAwaitMethod;
Copy link
Member

@jcouv jcouv Aug 22, 2025

Choose a reason for hiding this comment

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

Consider asserting that we either set runtimeAwaitMethod or the members related to non-runtime-async #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not a thing that can be asserted.

AssertEx.Equal("void System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.GetResult()", info.GetResultMethod.ToTestDisplayString());
AssertEx.Equal("System.Boolean System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.IsCompleted { get; }", info.IsCompletedProperty.ToTestDisplayString());
AssertEx.Equal(
"void System.Runtime.CompilerServices.AsyncHelpers.UnsafeAwaitAwaiter<System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter>(System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter awaiter)",
Copy link
Member

Choose a reason for hiding this comment

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

Consider also testing a scenario where RuntimeAwaitMethod is AwaitAwaiter instead of UnsafeAwaitAwaiter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Needs API Review Needs to be reviewed by the API review council

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Public API for runtime async

5 participants