roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

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

Open jjonescz opened this issue 11 months ago • 0 comments

Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/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
  • [x] Breaking change around unsafe context within iterators is documented
  • [ ] language version
    • [ ] ref / ref struct local in
      • [x] async method
      • [ ] iterator method
    • [ ] unsafe block is allowed in C# 13 in
      • [ ] async method (this is a preserved legacy behavior)
      • [x] iterator method
    • [x] unsafe modifier is allowed on an iterator in C# 13, still an error (a language version error) in previous versions
      • [x] regular method
      • [x] property get
      • [x] local function
      • [x] operator
    • [ ] effect on unsafe context within iterator's body (the breaking change)
      • [x] regular method
      • [ ] property get
      • [x] 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
  • [x] unsafe context
    • [x] unannotated / unsafe containing type
    • [x] unannotated / unsafe iterator method declaration
    • [x] unannotated / unsafe iterator block
    • [x] unannotated / unsafe local function
    • [x] unannotated lambda
    • [x] unannotated / unsafe property
    • [x] unannotated / unsafe property / indexer get iterator
  • [ ] within unsafe context
    • [ ] error for await (confirm we have a legacy test)
    • [x] error for yield return;
    • [x] no diagnostic for yield break;
  • [x] within lock
    • [x] next warning waive warning for yield return; for legacy lock
    • [x] error for yield return; for Lock type
    • [x] no diagnostic for yield break;
  • [x] taking address of local / parameter
    • [x] error in iterator method
    • [x] error in iterator method for an indirect case
    • [x] warning in async method (C#12 warning wave)
  • [x] taking address of a field is allowed in async/iterator

Related:

  • https://github.com/dotnet/csharplang/issues/1331

jjonescz avatar Mar 22 '24 10:03 jjonescz