-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-unsafe-in-iterators-async.md
Feature branch: https://github.com/dotnet/roslyn/tree/features/RefInAsync
Label: https://github.com/dotnet/roslyn/labels/New%20Feature%20-%20Ref%2FUnsafe%20in%20Iterators%2FAsync
- Review feature specification at LDM
- Breaking change around
unsafecontext within iterators is documented - language version
-
ref/ref structlocal in-
asyncmethod - iterator method
-
-
unsafeblock is allowed in C# 13 in-
asyncmethod (this is a preserved legacy behavior) - iterator method
-
-
unsafemodifier is allowed on an iterator in C# 13, still an error (a language version error) in previous versions- regular method
- property get
- local function
- operator
- effect on
unsafecontext within iterator's body (the breaking change)- regular method
- property get
- local function
- operator
-
- use
ref/ref structlocal- within / across
await - within / across
yield return;in- regular iterators
-
asynciterators
- across
yield break;in- regular iterators
-
asynciterators
- within / across
async foreachblock -
yieldin nested block - within
asynclambda / local function - within iterator local function
- within property / indexer
getiterator - error in
async/ iterator even inunsafecontext - await in elements of stackalloc, the result span should be usable afterwards
-
async Task<int[]> M() => ... ReadOnlySpan<int> x = await M();is expected to work -
Buffer2<int> b = [await a, await b]; // inline array type (ref struct) -
using (refStruct = ...) { await ...; } -
foreach (var _ in refStruct) { await ...; } - Interpolation handlers with awaits in the middle handler is a ref struct
- no awaits in async method should work
- Has await should be blocked (turns out it works but doesn't use the interpolation handler)
- within / across
-
unsafecontext- unannotated /
unsafecontaining type - unannotated /
unsafeiterator method declaration - unannotated /
unsafeiterator block - unannotated /
unsafelocal function - unannotated lambda
- unannotated /
unsafeproperty - unannotated /
unsafeproperty / indexergetiterator
- unannotated /
- within
unsafecontext- error for
await(confirm we have a legacy test) - error for
yield return; - no diagnostic for
yield break;
- error for
- within
lock- next warning waive warning for
yield return;for legacy lock - error for
yield return;forLocktype - no diagnostic for
yield break;
- next warning waive warning for
- taking address of local / parameter
- error in iterator method
- error in iterator method for an indirect case
- warning in
asyncmethod (C#12 warning wave)
- taking address of a field is allowed in
async/iterator
Related:
Reactions are currently unavailable