-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add RuntimeAwaitMethod to AwaitExpressionInfo #79968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@dotnet/roslyn-compiler for review |
| /// 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)", |
There was a problem hiding this comment.
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.
Closes #79818.