-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ namespace Microsoft.CodeAnalysis.CSharp | |
| /// <summary> | ||
| /// Structure containing all semantic information about an await expression. | ||
| /// </summary> | ||
| // https://github.com/dotnet/roslyn/issues/79818: Add runtime async info | ||
| public readonly struct AwaitExpressionInfo : IEquatable<AwaitExpressionInfo> | ||
| { | ||
| public IMethodSymbol? GetAwaiterMethod { get; } | ||
|
|
@@ -21,11 +20,30 @@ namespace Microsoft.CodeAnalysis.CSharp | |
|
|
||
| public bool IsDynamic { get; } | ||
|
|
||
| internal AwaitExpressionInfo(IMethodSymbol getAwaiter, IPropertySymbol isCompleted, IMethodSymbol getResult, bool isDynamic) | ||
| /// <summary> | ||
| /// 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 | ||
| /// supported task type. In such cases, <see cref="GetAwaiterMethod" />, | ||
| /// <see cref="IsCompletedProperty" />, and <see cref="GetResultMethod" /> will be | ||
| /// <see langword="null" />. | ||
| /// </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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We do set them in this case, because we will need them.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, I misread. We don't need the other members for |
||
| /// the rest of the await expression is successfully bound. | ||
| /// </item> | ||
| /// </list> | ||
| /// </summary> | ||
| public IMethodSymbol? RuntimeAwaitMethod { get; } | ||
|
|
||
| internal AwaitExpressionInfo(IMethodSymbol? getAwaiter, IPropertySymbol? isCompleted, IMethodSymbol? getResult, IMethodSymbol? runtimeAwaitMethod, bool isDynamic) | ||
| { | ||
| GetAwaiterMethod = getAwaiter; | ||
| IsCompletedProperty = isCompleted; | ||
| GetResultMethod = getResult; | ||
| RuntimeAwaitMethod = runtimeAwaitMethod; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider asserting that we either set
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a thing that can be asserted. |
||
| IsDynamic = isDynamic; | ||
| } | ||
|
|
||
|
|
@@ -39,12 +57,13 @@ public bool Equals(AwaitExpressionInfo other) | |
| return object.Equals(this.GetAwaiterMethod, other.GetAwaiterMethod) | ||
| && object.Equals(this.IsCompletedProperty, other.IsCompletedProperty) | ||
| && object.Equals(this.GetResultMethod, other.GetResultMethod) | ||
| && object.Equals(this.RuntimeAwaitMethod, other.RuntimeAwaitMethod) | ||
| && IsDynamic == other.IsDynamic; | ||
| } | ||
|
|
||
| public override int GetHashCode() | ||
| { | ||
| return Hash.Combine(GetAwaiterMethod, Hash.Combine(IsCompletedProperty, Hash.Combine(GetResultMethod, IsDynamic.GetHashCode()))); | ||
| return Hash.Combine(GetAwaiterMethod, Hash.Combine(IsCompletedProperty, Hash.Combine(GetResultMethod, Hash.Combine(RuntimeAwaitMethod, IsDynamic.GetHashCode())))); | ||
| } | ||
| } | ||
| } | ||
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