Skip to content

Commit f3a4725

Browse files
committed
fix: suppress PlatformNotSupportedException on Xamarin of macOS
1 parent 294a829 commit f3a4725

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/CommandLineUtils/IO/PhysicalConsole.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@ private PhysicalConsole()
2727
public event ConsoleCancelEventHandler? CancelKeyPress
2828
{
2929
add => Console.CancelKeyPress += value;
30-
remove => Console.CancelKeyPress -= value;
30+
remove
31+
{
32+
try
33+
{
34+
Console.CancelKeyPress -= value;
35+
}
36+
catch (PlatformNotSupportedException)
37+
{
38+
// https://github.com/natemcmaster/CommandLineUtils/issues/344
39+
// Suppress this error during unsubscription on some Xamarin platforms.
40+
}
41+
}
3142
}
3243

3344
/// <summary>

0 commit comments

Comments
 (0)