-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18498 from michaelnebel/csharp/refandunsafe
C# 13: [TEST ONLY] Test example with ref local, unsafe context and ref struct in async- and iterator methods.
- Loading branch information
Showing
6 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public ref struct RS | ||
{ | ||
public int GetZero() { return 0; } | ||
} | ||
|
||
public class C | ||
{ | ||
private int one = 1; | ||
|
||
// Test that we can use unsafe context, ref locals and ref structs in iterators. | ||
public IEnumerable<int> GetObjects() | ||
{ | ||
unsafe | ||
{ | ||
// Do pointer stuff | ||
} | ||
ref int i = ref one; | ||
RS rs; | ||
var zero = rs.GetZero(); | ||
yield return zero; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| iterators.cs:14:29:14:38 | GetObjects | iterators.cs:23:22:23:25 | access to local variable zero | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import csharp | ||
|
||
from Callable c, Expr return | ||
where c.canYieldReturn(return) | ||
select c, return |