Skip to content
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

Test plan for "ref and unsafe in iterators and async" feature #72662

Closed
61 of 62 tasks
jjonescz opened this issue Mar 22, 2024 · 0 comments · Fixed by #73488
Closed
61 of 62 tasks

Test plan for "ref and unsafe in iterators and async" feature #72662

jjonescz opened this issue Mar 22, 2024 · 0 comments · Fixed by #73488

Comments

@jjonescz
Copy link
Member

jjonescz commented Mar 22, 2024

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: New Feature - Ref/Unsafe in Iterators/Async

  • Review feature specification at LDM
  • Breaking change around unsafe context within iterators is documented
  • language version
    • ref / ref struct local in
      • async method
      • iterator method
    • unsafe block is allowed in C# 13 in
      • async method (this is a preserved legacy behavior)
      • iterator method
    • unsafe modifier 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 unsafe context within iterator's body (the breaking change)
      • regular method
      • property get
      • local function
      • operator
  • use ref / ref struct local
    • within / across await
    • within / across yield return; in
      • regular iterators
      • async iterators
    • across yield break; in
      • regular iterators
      • async iterators
    • within / across async foreach block
    • yield in nested block
    • within async lambda / local function
    • within iterator local function
    • within property / indexer get iterator
    • error in async / iterator even in unsafe context
    • 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)
  • unsafe context
    • unannotated / unsafe containing type
    • unannotated / unsafe iterator method declaration
    • unannotated / unsafe iterator block
    • unannotated / unsafe local function
    • unannotated lambda
    • unannotated / unsafe property
    • unannotated / unsafe property / indexer get iterator
  • within unsafe context
    • error for await (confirm we have a legacy test)
    • error for yield return;
    • no diagnostic for yield break;
  • within lock
    • next warning waive warning for yield return; for legacy lock
    • error for yield return; for Lock type
    • no diagnostic for yield break;
  • taking address of local / parameter
    • error in iterator method
    • error in iterator method for an indirect case
    • warning in async method (C#12 warning wave)
  • taking address of a field is allowed in async/iterator

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant