You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace "async method" with "async function" This feature applies to local functions and lambda expressions as well.
Put examples in an informative *Example* block
Update cross references as needed
Copy file name to clipboardExpand all lines: standard/classes.md
+55-53Lines changed: 55 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5872,77 +5872,79 @@ If the return type of the async function is `void`, evaluation differs from the
5872
5872
5873
5873
This allows the context to keep track of how many `void`-returning async functions are running under it, and to decide how to propagate exceptions coming out of them.
5874
5874
5875
-
Rather than using a task builder type based on the *return_type* of an async method, the attribute `AsyncMethodBuilder` can be applied to that method to indicate a different task builder type.
5875
+
Rather than using a task builder type based on the *return_type* of an async function, the attribute `AsyncMethodBuilder` can be applied to that async function to indicate a different task builder type.
5876
5876
5877
5877
It is an error to apply this attribute to a lambda with an implicit return type.
5878
5878
5879
5879
The ability to provide an alternate builder type shall not be used when the synthesized entry-point for top-level statements is async (§7.1.3). For that, an explicit entry-point is needed.
5880
5880
5881
-
When an async method is compiled, the builder type is determined by:
5881
+
When an async function is compiled, the builder type is determined by:
5882
5882
5883
5883
1. Using the builder type from the `AsyncMethodBuilder` attribute, if one is present;
5884
-
1. Otherwise, falling back to the builder type determined by the method's *return_type*.
5884
+
1. Otherwise, falling back to the builder type determined by the async function's *return_type* (§15.14.2).
5885
5885
5886
5886
If an `AsyncMethodBuilder` attribute is present, the builder type specified by that attribute is constructed, if necessary.
5887
5887
5888
-
If the override type is an open generic type, take the single type argument of the async method's return type and substitute it into the override type.
5888
+
If the override type is an open generic type, take the single type argument of the async function's return type and substitute it into the override type.
5889
5889
5890
5890
If the override type is a bound generic type, then an error results.
5891
5891
5892
-
If the async method's return type does not have a single type argument, an error results.
5892
+
If the async function's return type does not have a single type argument, an error results.
5893
5893
5894
-
To verify that the builder type is compatible with *return_type* of the async method:
5894
+
To verify that the builder type is compatible with *return_type* of the async function:
5895
5895
5896
5896
1. Look for the public `Create` method with no type parameters and no parameters on the constructed builder type. It is an error if the method is not found, or if the method returns a type other than the constructed builder type.
5897
5897
1. Look for the public `Task` property. It is an error if the property is not found.
5898
-
1. Consider the type of that `Task` property (a task-like type). It is an error if the task-like type does not match the *return_type* of the async method. (It is not necessary for *return_type* to be a task-like type.)
5898
+
1. Consider the type of that `Task` property (a task-like type). It is an error if the task-like type does not match the *return_type* of the async function. (It is not necessary for *return_type* to be a task-like type.)
5899
5899
5900
-
Consider the following code fragment:
5901
-
5902
-
```csharp
5903
-
public async ValueTask<T> ExampleAsync() { … }
5904
-
```
5905
-
5906
-
This will be compiled to something like the following:
0 commit comments