Skip to content

docs: Breaking change — SafeFileHandle.IsAsync and FileStream.IsAsync now reflect actual O_NONBLOCK state on Unix (.NET 11)#52888

Open
Copilot wants to merge 5 commits intomainfrom
copilot/fix-safe-file-handle-is-async
Open

docs: Breaking change — SafeFileHandle.IsAsync and FileStream.IsAsync now reflect actual O_NONBLOCK state on Unix (.NET 11)#52888
Copilot wants to merge 5 commits intomainfrom
copilot/fix-safe-file-handle-is-async

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

In .NET 11 Preview 3, SafeFileHandle.IsAsync and FileStream.IsAsync on Unix changed from always returning true for files opened with FileOptions.Asynchronous to accurately reflecting whether O_NONBLOCK is set on the file descriptor. Regular files now return false; only genuinely non-blocking fds (pipes, sockets) return true.

Changes

  • New article docs/core/compatibility/core-libraries/11/safefilehandle-isasync-unix.md covering:
    • SafeFileHandle.IsAsync / FileStream.IsAsync Unix behavior change
    • SendPacketsElement(FileStream, ...) no longer throws ArgumentException on non-Windows for non-async streams
    • Recommended actions for each impacted scenario
  • 11.md — added row under Core .NET libraries
  • toc.yml — added entry under .NET 11 > Core .NET libraries

Behavior at a glance

// Before (.NET 10): always true for FileOptions.Asynchronous on Unix
using SafeFileHandle h = File.OpenHandle("file.txt", options: FileOptions.Asynchronous);
Console.WriteLine(h.IsAsync); // true (misleading — no O_NONBLOCK on regular file)

// After (.NET 11): reflects actual fd state
SafeFileHandle.CreateAnonymousPipe(out var read, out var write, asyncRead: true, asyncWrite: false);
Console.WriteLine(read.IsAsync);  // true  (O_NONBLOCK set)
Console.WriteLine(write.IsAsync); // false (blocking)
// Regular file: false

Internal previews

📄 File 🔗 Preview link
docs/core/compatibility/11.md Breaking changes in .NET 11
docs/core/compatibility/core-libraries/11/safefilehandle-isasync-unix.md SafeFileHandle.IsAsync and FileStream.IsAsync accurately reflect non-blocking state on Unix
docs/core/compatibility/toc.yml docs/core/compatibility/toc

…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>
Copilot AI changed the title [WIP] Fix SafeFileHandle.IsAsync to reflect non-blocking state on Unix docs: Breaking change — SafeFileHandle.IsAsync and FileStream.IsAsync now reflect actual O_NONBLOCK state on Unix (.NET 11) Apr 7, 2026
Copilot AI requested a review from gewarren April 7, 2026 17:24
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.
@gewarren gewarren marked this pull request as ready for review April 7, 2026 20:19
@gewarren gewarren requested a review from a team as a code owner April 7, 2026 20:19
@gewarren gewarren requested review from adamsitnik and Copilot April 7, 2026 20:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 IsAsync behavior update (and related SendPacketsElement behavior 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.

Copilot AI requested a review from gewarren April 7, 2026 20:29
Clarified the behavior of SafeFileHandle.IsAsync on Unix regarding asynchronous and non-blocking file descriptors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Breaking change]: SafeFileHandle.IsAsync now accurately reflects non-blocking state on Unix

3 participants