Skip to content

Commit 7942dee

Browse files
authored
[release/10.0.1xx-preview5] [SystemConfiguration] Fix accidental break in NetworkReachability.Schedule|Unschedule. (#22914)
Fixes dotnet/maui#29678. Backport of #22912.
1 parent f676a8d commit 7942dee

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/SystemConfiguration/NetworkReachability.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public bool Schedule (CFRunLoop runLoop, string mode)
576576
if (mode is null)
577577
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (mode));
578578

579-
using var modeHandle = new TransientString (mode);
579+
using var modeHandle = new TransientCFString (mode);
580580
bool result = SCNetworkReachabilityScheduleWithRunLoop (Handle, runLoop.GetCheckedHandle (), modeHandle) != 0;
581581
GC.KeepAlive (runLoop);
582582
return result;
@@ -629,7 +629,7 @@ public bool Unschedule (CFRunLoop runLoop, string mode)
629629
if (mode is null)
630630
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (mode));
631631

632-
using var modeHandle = new TransientString (mode);
632+
using var modeHandle = new TransientCFString (mode);
633633
bool result = SCNetworkReachabilityUnscheduleFromRunLoop (Handle, runLoop.GetCheckedHandle (), modeHandle) != 0;
634634
GC.KeepAlive (runLoop);
635635
return result;

tests/monotouch-test/SystemConfiguration/NetworkReachabilityTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99

1010
using System;
11+
using CoreFoundation;
1112
using Foundation;
1213
#if !MONOMAC
1314
using UIKit;
@@ -137,5 +138,14 @@ public void Ctor_Invalid ()
137138
} catch (ArgumentException) {
138139
}
139140
}
141+
142+
[Test]
143+
public void Schedule ()
144+
{
145+
var ip = new IPAddress (0);
146+
using var defaultRouteReachability = new NetworkReachability (ip);
147+
Assert.IsTrue (defaultRouteReachability.Schedule (CFRunLoop.Main, CFRunLoop.ModeDefault), "Schedule");
148+
Assert.IsTrue (defaultRouteReachability.Unschedule (CFRunLoop.Main, CFRunLoop.ModeDefault), "Unschedule");
149+
}
140150
}
141151
}

0 commit comments

Comments
 (0)