Skip to content

[Network] Correct NWEstablishmentReport enumeration callback return values. - #26798

Merged
rolfbjarne merged 4 commits into
mainfrom
dev/rolf/establishment-report-callback-bindings
Oct 3, 2026
Merged

rolfbjarne merged 4 commits into
mainfrom
dev/rolf/establishment-report-callback-bindings

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

The native resolution, protocol, and resolution-report enumerators return a Boolean indicating whether enumeration should continue. Return byte 1 from their unmanaged trampolines and update the matching function pointers so the existing Action-based managed API consistently continues enumeration.

Extract the binding corrections and related coverage from #26704 without its GC.KeepAlive changes. Add a dedicated TCP protocol-enumeration test with a bounded establishment-report wait and explicit cleanup, preserving the shared UDP fixture. Exercise resolution-report enumeration on devices and require at least one report.

🤖 Pull request created by Copilot

…alues.

The native resolution, protocol, and resolution-report enumerators return a Boolean indicating whether enumeration should continue. Return byte 1 from their unmanaged trampolines and update the matching function pointers so the existing Action-based managed API consistently continues enumeration.

Extract the binding corrections and related coverage from #26704 without its GC.KeepAlive changes. Add a dedicated TCP protocol-enumeration test with a bounded establishment-report wait and explicit cleanup, preserving the shared UDP fixture. Exercise resolution-report enumeration on devices and require at least one report.

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:07
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner October 1, 2026 07:07

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 new tests only verify the first callback and do not regress continuation behavior.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Corrects Network establishment-report trampolines so native enumeration consistently continues.

Changes:

  • Return native Boolean 1 from three enumeration callbacks.
  • Add protocol and resolution-report coverage.
File Description
src/​Network/​NWEstablishmentReport.cs Corrects unmanaged callback return signatures.
tests/​monotouch-test/​Network/​NWEstablishmentReportTest.cs Adds enumeration tests and cleanup.

Comment thread src/Network/NWEstablishmentReport.cs Resolved
Comment thread src/Network/NWEstablishmentReport.cs Resolved
Comment thread src/Network/NWEstablishmentReport.cs Resolved
Comment thread src/Network/NWEstablishmentReport.cs Resolved
Return false from all three enumeration trampolines when their managed target is missing, matching other Network enumerators. Only report successful continuation after invoking the handler.

Exercise protocol enumeration on a TLS-over-TCP connection and require both TCP and TLS definitions, rather than accepting one callback. Bound connection and report waits, cancel the connection in cleanup, and dispose reports even if their callback arrives after a timeout. Keep the shared UDP fixture and resolution-report smoke coverage unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 07:41
Document the five callback arguments, synchronous invocation, null-handler exception, and callback-scoped endpoint lifetime for EnumerateResolutions, as requested in review.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Three fallback paths still return false, contradicting the stated always-continue callback contract.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread src/Network/NWEstablishmentReport.cs Resolved
@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.

…o callers

The establishment-report callback receives a borrowed report, but its wrapper claimed ownership without retaining it. Disposing the report in the new protocol test freed an object still used by Network during connection cancellation, causing a native crash after the test passed. Retain the callback report through NativeObject so its managed lifetime is independent of the connection.

Remove the documentation known-failure entry for EnumerateResolutions, which is now documented and caused the Cecil CI job to fail.

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

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

🔵 Needs a closer look

The establishment-report callback still mishandles the native API’s nullable report value.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Return null for unavailable establishment reports

src/​Network/​NWConnection.cs:660

🤖 ❌ Binding definition — Apple's nw_establishment_report_access_block_t marks report nullable and documents that it is NULL until the connection is ready. This path still creates and passes a non-null NWEstablishmentReport with a zero handle, so callers receive an unusable wrapper instead of null. Check for IntPtr.Zero here and update the target/public callback contract to Action<NWEstablishmentReport?>; add coverage for requesting the report before readiness.

Rule: Match native nullability contracts

@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: 0fbcd2e86cba8273607adca8328afb9eff1b852f [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #0fbcd2e] 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: 0fbcd2e86cba8273607adca8328afb9eff1b852f [PR build]

@rolfbjarne
rolfbjarne enabled auto-merge (squash) October 2, 2026 18:30
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Oct 2, 2026
@rolfbjarne
rolfbjarne merged commit bd0950d into main Oct 3, 2026
56 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/establishment-report-callback-bindings branch October 3, 2026 12:25
rolfbjarne added a commit that referenced this pull request Nov 27, 2026
…n callback return values. (#27493)

The native resolution, protocol, and resolution-report enumerators return a Boolean indicating whether enumeration should continue. Return byte 1 from their unmanaged trampolines and update the matching function pointers so the existing Action-based managed API consistently continues enumeration.

Extract the binding corrections and related coverage from #26704 without its GC.KeepAlive changes. Add a dedicated TCP protocol-enumeration test with a bounded establishment-report wait and explicit cleanup, preserving the shared UDP fixture. Exercise resolution-report enumeration on devices and require at least one report.

Applied without conflicts or dependencies. No app-size expectations changed or needed regeneration.

Backport of #26798.

🤖 Pull request created by Copilot

---------

Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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