-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "ref in async" feature into main (#73488)
- Loading branch information
Showing
61 changed files
with
10,695 additions
and
1,426 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md
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,27 @@ | ||
# This document lists known breaking changes in Roslyn after .NET 8 all the way to .NET 9. | ||
|
||
## Iterators introduce safe context in C# 13 and newer | ||
|
||
***Introduced in Visual Studio 2022 version 17.11*** | ||
|
||
Although the language spec states that iterators introduce a safe context, Roslyn does not implement that in C# 12 and lower. | ||
This will change in C# 13 as part of [a feature which allows unsafe code in iterators](https://github.com/dotnet/roslyn/issues/72662). | ||
The change does not break normal scenarios as it was disallowed to use unsafe constructs directly in iterators anyway. | ||
However, it can break scenarios where an unsafe context was previously inherited into nested local functions, for example: | ||
|
||
```cs | ||
unsafe class C // unsafe context | ||
{ | ||
System.Collections.Generic.IEnumerable<int> M() // an iterator | ||
{ | ||
yield return 1; | ||
local(); | ||
void local() | ||
{ | ||
int* p = null; // allowed in C# 12; error in C# 13 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
You can work around the break simply by adding the `unsafe` modifier to the local function. |
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
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
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
Oops, something went wrong.