Conversation
…change in .NET 11 Agent-Logs-Url: https://github.com/dotnet/docs/sessions/8ae53bcd-ed7a-4368-898a-433576b68e76 Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Corrected the behavior of SafeFileHandle.IsAsync on Unix to accurately reflect the non-blocking state of file descriptors. Updated documentation to clarify the changes and their implications.
There was a problem hiding this comment.
Pull request overview
Adds a new .NET 11 breaking change article documenting updated Unix semantics for SafeFileHandle.IsAsync and FileStream.IsAsync, and wires the article into the .NET compatibility index and TOC.
Changes:
- Adds a new breaking change article describing the Unix
IsAsyncbehavior update (and relatedSendPacketsElementbehavior on non-Windows). - Updates the .NET 11 breaking changes index to include the new entry.
- Updates the compatibility TOC to surface the new article under .NET 11 > Core .NET libraries.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/core/compatibility/core-libraries/11/safefilehandle-isasync-unix.md | New breaking change article describing the updated Unix IsAsync behavior and recommended actions. |
| docs/core/compatibility/11.md | Adds the new breaking change link to the .NET 11 index table. |
| docs/core/compatibility/toc.yml | Adds a TOC entry so the new article appears in navigation. |
| ## Previous behavior | ||
|
|
||
| Previously, `SafeFileHandle.IsAsync` always returned `true` on Unix for regular files opened with `FileOptions.Asynchronous`, regardless of whether the underlying file descriptor had the `O_NONBLOCK` flag set. | ||
|
|
||
| ```csharp | ||
| using Microsoft.Win32.SafeHandles; | ||
|
|
||
| // On Unix, IsAsync was true for regular files opened with FileOptions.Asynchronous, | ||
| // even though the file descriptor had no O_NONBLOCK set. | ||
| using SafeFileHandle handle = File.OpenHandle("myfile.txt", options: FileOptions.Asynchronous); | ||
| Console.WriteLine(handle.IsAsync); // true (misleading; no O_NONBLOCK on regular file) | ||
| ``` | ||
|
|
||
| On non-Windows platforms, constructing a `SendPacketsElement` with a non-async `FileStream` threw an `ArgumentException`. | ||
|
|
There was a problem hiding this comment.
The "Reason for change" section says SafeFileHandle.IsAsync previously reported false for genuinely non-blocking file descriptors (pipes/sockets with O_NONBLOCK), but the "Previous behavior" section only describes the regular-file scenario. Add a sentence in "Previous behavior" clarifying the pipe/socket case (and that the value was based on the open options rather than actual O_NONBLOCK) so the narrative doesn’t read as contradictory.
There was a problem hiding this comment.
Updated in 2a1f4e0. The "Previous behavior" section now explicitly describes both scenarios: regular files returning true despite no O_NONBLOCK (values based on open options), and genuinely non-blocking pipes/sockets incorrectly returning false.
Agent-Logs-Url: https://github.com/dotnet/docs/sessions/106a7ea2-8628-4d51-9f8a-e8a93476426d Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Clarified the behavior of SafeFileHandle.IsAsync on Unix regarding asynchronous and non-blocking file descriptors.
In .NET 11 Preview 3,
SafeFileHandle.IsAsyncandFileStream.IsAsyncon Unix changed from always returningtruefor files opened withFileOptions.Asynchronousto accurately reflecting whetherO_NONBLOCKis set on the file descriptor. Regular files now returnfalse; only genuinely non-blocking fds (pipes, sockets) returntrue.Changes
docs/core/compatibility/core-libraries/11/safefilehandle-isasync-unix.mdcovering:SafeFileHandle.IsAsync/FileStream.IsAsyncUnix behavior changeSendPacketsElement(FileStream, ...)no longer throwsArgumentExceptionon non-Windows for non-async streams11.md— added row under Core .NET librariestoc.yml— added entry under .NET 11 > Core .NET librariesBehavior at a glance
Internal previews