-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set state of enumerator object to "after" during disposal (#76090)
- Loading branch information
Showing
12 changed files
with
2,821 additions
and
751 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
37 changes: 37 additions & 0 deletions
37
docs/compilers/Visual Basic/Compiler Breaking Changes - DotNet 10.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,37 @@ | ||
# Breaking changes in Roslyn after .NET 9.0.100 through .NET 10.0.100 | ||
|
||
This document lists known breaking changes in Roslyn after .NET 9 general release (.NET SDK version 9.0.100) through .NET 10 general release (.NET SDK version 10.0.100). | ||
|
||
## Set state of enumerator object to "after" during disposal | ||
|
||
***Introduced in Visual Studio 2022 version 17.13*** | ||
|
||
The state machine for enumerators incorrectly allowed resuming execution after the enumerator was disposed. | ||
Now, `MoveNext()` on a disposed enumerator properly returns `false` without executing any more user code. | ||
|
||
```vb | ||
Imports System | ||
Imports System.Collections.Generic | ||
|
||
Module Program | ||
Sub Main() | ||
Dim enumerator = C.GetEnumerator() | ||
|
||
Console.Write(enumerator.MoveNext()) ' prints True | ||
Console.Write(enumerator.Current) ' prints 1 | ||
|
||
enumerator.Dispose() | ||
|
||
Console.Write(enumerator.MoveNext()) ' now prints False | ||
End Sub | ||
End Module | ||
|
||
Class C | ||
Public Shared Iterator Function GetEnumerator() As IEnumerator(Of Integer) | ||
Yield 1 | ||
Console.Write("not executed after disposal") | ||
Yield 2 | ||
End Function | ||
End Class | ||
``` | ||
|
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.