Skip to content

[Network] Fix WebSocket response header bindings - #26800

Merged
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/websocket-response-binding-fixes
Oct 3, 2026
Merged

rolfbjarne merged 3 commits into
mainfrom
dev/rolf/websocket-response-binding-fixes

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Fix two binding errors in NWWebSocketResponse:

  • Return a native boolean (byte, with 1 to continue enumeration) from the additional-header callback, and update its function-pointer signature to match. The previous void callback did not provide the continuation result expected by Network.framework.
  • Forward the transient header-name and value pointers to the native nw_ws_response_add_additional_header overload. Passing the original strings recursively called the managed wrapper instead.

Add a regression test that sets two headers and verifies that enumeration completes and returns both names and values.

This independently extracts only the binding fixes and their test from #26704. All GC.KeepAlive guards and associated result locals remain in that separate change.

🤖 Pull request created by Copilot

Return a native boolean from the response header enumeration trampoline and match its function-pointer signature so enumeration continues through every header. Forward transient header-name and value pointers to the native overload instead of recursively calling the managed string overload.

Add a regression test that sets two headers and verifies successful enumeration and both values. Extract only these binding corrections from #26704; native-owner lifetime guards remain in that separate change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 07:11
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner October 1, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The trampoline incorrectly reports continuation when its managed callback target is unavailable.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes native interop for WebSocket response headers and adds regression coverage.

Changes:

  • Corrects enumeration callback return ABI.
  • Forwards transient native string pointers correctly.
  • Tests two-header enumeration.
File Description
src/​Network/​NWWebSocketResponse.cs Fixes callback and header forwarding bindings.
tests/​monotouch-test/​Network/​NWWebSocketResponseTest.cs Adds regression coverage.

Comment thread src/Network/NWWebSocketResponse.cs Resolved
Comment thread src/Network/NWWebSocketResponse.cs Resolved
Return false from the native enumeration trampoline when its managed target is missing, and report continuation only after delivering the header to the handler. This matches the failure behavior of the other Network enumeration trampolines.

Document EnumerateAdditionalHeaders, including callback arguments, synchronous invocation, completion status, and null-handler validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 07:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The binding fixes match established interop patterns and are covered by a focused regression test.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Comment thread src/Network/NWWebSocketResponse.cs Resolved
Copilot AI balanced review requested due to automatic review settings October 2, 2026 18:34
@rolfbjarne
rolfbjarne enabled auto-merge (squash) October 2, 2026 18:35
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Oct 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The binding fixes match native contracts and are covered by a focused regression test.

Review effort: Balanced
Findings: None

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 2b77610f0f963189a9ba1e64db2d8484e0822c55 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #2b77610] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 221 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 21 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 20 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 2b77610f0f963189a9ba1e64db2d8484e0822c55 [PR build]

@rolfbjarne
rolfbjarne merged commit d100de7 into main Oct 3, 2026
56 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/websocket-response-binding-fixes branch October 3, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants