Skip to content

Commit 0ad29bf

Browse files
[create-pull-request] automated change (#1418)
Co-authored-by: BillWagner <[email protected]>
1 parent f39791f commit 0ad29bf

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

standard/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@
493493
- [§13.12](statements.md#1312-the-checked-and-unchecked-statements) The checked and unchecked statements
494494
- [§13.13](statements.md#1313-the-lock-statement) The lock statement
495495
- [§13.14](statements.md#1314-the-using-statement) The using statement
496+
- [§13.14.1](statements.md#13141-general) General
497+
- [§13.14.2](statements.md#13142-using-declaration) Using declaration
496498
- [§13.15](statements.md#1315-the-yield-statement) The yield statement
497499
- [§14](namespaces.md#14-namespaces) Namespaces
498500
- [§14.1](namespaces.md#141-general) General
@@ -771,6 +773,7 @@
771773
- [§23.5.7.8](attributes.md#23578-the-notnull-attribute) The NotNull attribute
772774
- [§23.5.7.9](attributes.md#23579-the-notnullifnotnull-attribute) The NotNullIfNotNull attribute
773775
- [§23.5.7.10](attributes.md#235710-the-notnullwhen-attribute) The NotNullWhen attribute
776+
- [§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute) The EnumeratorCancellation attribute
774777
- [§23.6](attributes.md#236-attributes-for-interoperation) Attributes for interoperation
775778
- [§24](unsafe-code.md#24-unsafe-code) Unsafe code
776779
- [§24.1](unsafe-code.md#241-general) General

standard/attributes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ A number of attributes affect the language in some way. These attributes include
495495
- `System.ObsoleteAttribute` ([§23.5.4](attributes.md#2354-the-obsolete-attribute)), which is used to mark a member as obsolete.
496496
- `System.Runtime.CompilerServices.AsyncMethodBuilderAttribute` ([§23.5.5](attributes.md#2355-the-asyncmethodbuilder-attribute)), which is used to establish a task builder for an async method.
497497
- `System.Runtime.CompilerServices.CallerLineNumberAttribute` ([§23.5.6.2](attributes.md#23562-the-callerlinenumber-attribute)), `System.Runtime.CompilerServices.CallerFilePathAttribute` ([§23.5.6.3](attributes.md#23563-the-callerfilepath-attribute)), and `System.Runtime.CompilerServices.CallerMemberNameAttribute` ([§23.5.6.4](attributes.md#23564-the-callermembername-attribute)), which are used to supply information about the calling context to optional parameters.
498-
- `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` (§enumerator-cancellation), which is used to specify parameter for the cancellation token in an asynchronous iterator.
498+
- `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` ([§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute)), which is used to specify parameter for the cancellation token in an asynchronous iterator.
499499
500500
The Nullable static analysis attributes ([§23.5.7](attributes.md#2357-code-analysis-attributes)) can improve the correctness of warnings generated for nullabilities and null states ([§8.9.5](types.md#895-nullabilities-and-null-states)).
501501
@@ -1061,17 +1061,17 @@ Specifies that a nullable argument won’t be `null` when the method returns the
10611061
>
10621062
> *end example*
10631063
1064-
### §enumerator-cancellation The EnumeratorCancellation attribute
1064+
### 23.5.8 The EnumeratorCancellation attribute
10651065
1066-
Specifies the parameter representing the `CancellationToken` for an asynchronous iterator15.15). The argument for this parameter shall be combined with the argument passed to `IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken)`. This combined token shall be polled by `IAsyncEnumerator<T>.MoveNextAsync()` (§15.15.5.2). The tokens shall be combined into a single token as if by `CancellationToken.CreateLinkedTokenSource` and its `Token` property. The combined token will be canceled if either of the two source tokens are canceled. The combined token is seen as the argument to the asynchronous iterator method15.15) in the body of that method.
1066+
Specifies the parameter representing the `CancellationToken` for an asynchronous iterator ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)). The argument for this parameter shall be combined with the argument passed to `IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken)`. This combined token shall be polled by `IAsyncEnumerator<T>.MoveNextAsync()` ([§15.15.5.2](classes.md#151552-advance-the-enumerator)). The tokens shall be combined into a single token as if by `CancellationToken.CreateLinkedTokenSource` and its `Token` property. The combined token will be canceled if either of the two source tokens are canceled. The combined token is seen as the argument to the asynchronous iterator method ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)) in the body of that method.
10671067
10681068
It is an error if the `System.Runtime.CompilerServices.EnumeratorCancellation` attribute is applied to more than one parameter. The compiler may produce a warning if:
10691069
10701070
- The `EnumeratorCancellation` attribute is applied to a parameter of a type other than `CancellationToken`,
1071-
- or if the `EnumeratorCancellation` attribute is applied to a parameter on a method that isn't an asynchronous iterator15.15),
1071+
- or if the `EnumeratorCancellation` attribute is applied to a parameter on a method that isnt an asynchronous iterator ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)),
10721072
- or if the `EnumeratorCancellation` attribute is applied to a parameter on a method that returns an asynchronous enumerable interface ([§15.15.3](classes.md#15153-enumerable-interfaces)) rather than an asynchronous enumerator interface ([§15.15.2](classes.md#15152-enumerator-interfaces)).
10731073
1074-
The iterator won't have access to the `CancellationToken` argument for `GetAsyncEnumerator` when no attributes have this parameter.
1074+
The iterator wont have access to the `CancellationToken` argument for `GetAsyncEnumerator` when no attributes have this parameter.
10751075
10761076
> *Example*: The method `GetStringsAsync()` is an asynchronous iterator. Before doing any work to retrieve the next value, it checks the cancellation token to determine if the iteration should be canceled. If cancellation is requested, no further action is taken.
10771077
>

standard/classes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5504,7 +5504,7 @@ An iterator block may occur as a *method_body*, *operator_body* or *accessor_bod
55045504

55055505
When a function is implemented using an iterator block, it is a compile-time error for the parameter list of the function to specify any `in`, `out`, or `ref` parameters, or a parameter of a `ref struct` type.
55065506

5507-
An asynchronous iterator shall support cancellation of the asynchronous operation. This is described in §enumerator-cancellation.
5507+
An asynchronous iterator shall support cancellation of the asynchronous operation. This is described in [§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute).
55085508

55095509
### 15.15.2 Enumerator interfaces
55105510

@@ -5575,7 +5575,7 @@ The precise action performed by `MoveNext` or `MoveNextAsync` depends on the sta
55755575

55765576
When `MoveNext` executes the iterator block, execution can be interrupted in four ways: By a `yield return` statement, by a `yield break` statement, by encountering the end of the iterator block, and by an exception being thrown and propagated out of the iterator block.
55775577

5578-
> *Note*: `MoveNextAsync` is suspended if it evaluates an `await` expression that awaits a task type that hasn't completed. *end note*
5578+
> *Note*: `MoveNextAsync` is suspended if it evaluates an `await` expression that awaits a task type that hasnt completed. *end note*
55795579
55805580
- When a `yield return` statement is encountered ([§9.4.4.20](variables.md#94420-yield-statements)):
55815581
- The expression given in the statement is evaluated, implicitly converted to the yield type, and assigned to the `Current` property of the enumerator object.
@@ -5622,7 +5622,7 @@ The `Dispose` or `DisposeAsync` method is used to clean up the iteration by brin
56225622

56235623
When a function member or local function returning an enumerable interface type or an async enumerable interface type is implemented using an iterator block, invoking the function does not immediately execute the code in the iterator block. Instead, an ***enumerable object*** is created and returned.
56245624

5625-
A synchronous enumerable object implements `IEnumerable` and `IEnumerable<T>`, where `T` is the yield type of the iterator. Its `GetEnumerator` method returns an enumerator object (§15.15.5). An async enumerable object implements `IAsyncEnumerable<T>` where `T` is the yield type of the iterator. Its `GetAsyncEnumerator` method returns an asynchronous enumerator object (§15.15.5).
5625+
A synchronous enumerable object implements `IEnumerable` and `IEnumerable<T>`, where `T` is the yield type of the iterator. Its `GetEnumerator` method returns an enumerator object ([§15.15.5](classes.md#15155-enumerator-objects)). An async enumerable object implements `IAsyncEnumerable<T>` where `T` is the yield type of the iterator. Its `GetAsyncEnumerator` method returns an asynchronous enumerator object ([§15.15.5](classes.md#15155-enumerator-objects)).
56265626

56275627
An enumerable object is initialized with a copy of the argument values (if any) and instance value passed to the function.
56285628

@@ -5636,4 +5636,4 @@ An enumerable object may implement more interfaces than those specified above.
56365636

56375637
An enumerable object provides an implementation of the `GetEnumerator` methods of the `IEnumerable` and `IEnumerable<T>` interfaces. The two `GetEnumerator` methods share a common implementation that acquires and returns an available enumerator object. The enumerator object is initialized with the argument values and instance value saved when the enumerable object was initialized, but otherwise the enumerator object functions as described in [§15.15.5](classes.md#15155-enumerator-objects).
56385638

5639-
An asynchronous enumerable object provides an implementation of the `GetAsyncEnumerator` method of the `IAsyncEnumerable<T>` interface. This method returns an available asynchronous enumerator object. The enumerator object is initialized with the argument values and instance value saved when the enumerable object was initialized, including the optional cancellation token, but otherwise the enumerator object functions as described in [§15.15.5](classes.md#15155-enumerator-objects). An asynchronous iterator method can mark one parameter as the cancellation token using `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` (§enumerator-cancellation). An implementation shall provide a mechanism to combine cancellation tokens such that an asynchronous iterator is canceled when either cancellation token (the argument to `GetAsyncEnumerator` or the argument attributed with the attribute `System.Runtime.CompilerServices.EnumeratorCancellationAttribute`) requests cancellation.
5639+
An asynchronous enumerable object provides an implementation of the `GetAsyncEnumerator` method of the `IAsyncEnumerable<T>` interface. This method returns an available asynchronous enumerator object. The enumerator object is initialized with the argument values and instance value saved when the enumerable object was initialized, including the optional cancellation token, but otherwise the enumerator object functions as described in [§15.15.5](classes.md#15155-enumerator-objects). An asynchronous iterator method can mark one parameter as the cancellation token using `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` ([§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute)). An implementation shall provide a mechanism to combine cancellation tokens such that an asynchronous iterator is canceled when either cancellation token (the argument to `GetAsyncEnumerator` or the argument attributed with the attribute `System.Runtime.CompilerServices.EnumeratorCancellationAttribute`) requests cancellation.

standard/grammar.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,16 +1838,26 @@ lock_statement
18381838
: 'lock' '(' expression ')' embedded_statement
18391839
;
18401840
1841-
// Source: §13.14 The using statement
1841+
// Source: §13.14.1 General
18421842
using_statement
1843-
: 'using' '(' resource_acquisition ')' embedded_statement
1843+
: 'await'? 'using' '(' resource_acquisition ')' embedded_statement
18441844
;
18451845
18461846
resource_acquisition
1847-
: local_variable_declaration
1847+
: non_ref_local_variable_declaration
18481848
| expression
18491849
;
18501850
1851+
non_ref_local_variable_declaration
1852+
: implicitly_typed_local_variable_declaration
1853+
| explicitly_typed_local_variable_declaration
1854+
;
1855+
1856+
// Source: §13.14.2 Using declaration
1857+
using_declaration
1858+
: 'await'? 'using' non_ref_local_variable_declaration ';' statement_list?
1859+
;
1860+
18511861
// Source: §13.15 The yield statement
18521862
yield_statement
18531863
: 'yield' 'return' expression ';'

0 commit comments

Comments
 (0)