Skip to content

[Network] Correct Ethernet channel state callbacks. Fixes #26789 - #26871

Open
rolfbjarne wants to merge 3 commits into
mainfrom
dev/rolf/issue-26789-verification
Open

rolfbjarne wants to merge 3 commits into
mainfrom
dev/rolf/issue-26789-verification

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Add a SetStateChangesHandler overload accepting Action<NWEthernetChannelState, NWError?> so the registered delegate matches the native Ethernet channel callback and its trampoline.

Preserve the existing NWBrowserState overload behind !XAMCORE_5_0, mark it obsolete and hidden, and assign OverloadResolutionPriority (-1) so implicit callbacks select the correctly typed overload. Forward legacy handlers through the new overload, retaining the native numeric state without a delegate-type mismatch.

Document the corrected overload, including its optional error and null-handler removal behavior, and update the corresponding documentation known-failure entry. Add macOS regression coverage for both overloads, using task completion sources to avoid late callbacks touching disposed synchronization objects.

Fixes #26789

🤖 Pull request created by Copilot

rolfbjarne and others added 3 commits October 14, 2026 17:36
Use the Ethernet channel state enum in the public callback signature so the block target matches the native trampoline. Add macOS coverage that starts a channel on a wired interface and checks that a native state callback delivers an Ethernet channel state when the custom-protocol entitlement is available.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Describe when the correctly typed state-change callback runs, the Ethernet state and optional error it receives, and how passing null clears the handler. Keep the deprecated compatibility overload and all behavior unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use task completion sources for path and state callbacks so asynchronous notifications cannot signal disposed events during teardown. Capture only the first callback result and cancel the path monitor even when its wait fails. Include the component-model namespace required by the legacy overload visibility attribute.

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

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.

🟡 Changes recommended

The runtime regression test is unconditionally skipped in CI, leaving the failing callback path untested.

2 open findings
What changed in this PR

Corrects Ethernet channel callbacks to use NWEthernetChannelState while preserving compatibility.

Changes:

  • Adds the correctly typed overload and legacy forwarding.
  • Updates XML documentation tracking.
  • Adds macOS callback regression coverage.
File Description
src/​Network/​NWEthernetChannel.cs Corrects callback typing and preserves the legacy API.
tests/​monotouch-test/​Network/​NWEthernetChannelTest.cs Tests corrected and legacy callbacks.
tests/​cecil-tests/​Documentation.KnownFailures.txt Updates documentation expectations.

🧠 Review effort: Balanced

public void StateChangesHandler (bool useLegacyHandler)
{
TestRuntime.AssertXcodeVersion (11, 0);
TestRuntime.IgnoreInCI ("This test requires a wired interface and the custom-protocol entitlement.");
#if !XAMCORE_5_0
[BindingImpl (BindingImplOptions.Optimizable)]
[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete ("Use the other overload.")]
@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: 5c694a91d3ac9a7275b31170f10d0d6eeed73d20 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #5c694a9] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 2 tests failed, 219 tests passed.

Failures

❌ linker tests (iOS)

1 tests failed, 20 tests passed.

Failed tests

  • dont link/iOS - simulator/Debug (PrepareAssemblies, CoreCLR, Managed Static Registrar): LaunchFailure

Html Report (VSDrops) Download

❌ monotouch tests (iOS)

1 tests failed, 19 tests passed.

Failed tests

  • monotouch-test/iOS - simulator/Release (compat inline dlfcn): LaunchTimedOut

Html Report (VSDrops) Download

Successes

✅ 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 (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 (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: 5c694a91d3ac9a7275b31170f10d0d6eeed73d20 [PR build]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Network] Use Ethernet channel state type in SetStateChangesHandler

3 participants