From bd35d0d2e50324bc225de9f6521fc91974f7373f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 29 Aug 2024 14:17:50 +0200 Subject: [PATCH] [Foundation] Allow setting NSUrlSessionHandler.Proxy to null (#21140) Before PR: NSUrlSessionHandler.Proxy property throws NSE when client code set any value (including `null`): ![image](https://github.com/user-attachments/assets/bb273910-3519-490f-b5fd-1999327012b3) After PR NSUrlSessionHandler.Proxy property throws NSE only when the client code tries to set a value different from `null` (Custom proxy is not supported right now in iOS implementation so setting a value other than null must throws NSE): ![image](https://github.com/user-attachments/assets/4a564785-3e23-469c-ac26-460d028cf770) Fixes #21132. PR originally submitted by @adospace in #21137. Co-authored-by: adospace --- src/Foundation/NSUrlSessionHandler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Foundation/NSUrlSessionHandler.cs b/src/Foundation/NSUrlSessionHandler.cs index 638211139a35..a2029e14a34d 100644 --- a/src/Foundation/NSUrlSessionHandler.cs +++ b/src/Foundation/NSUrlSessionHandler.cs @@ -651,7 +651,10 @@ public bool PreAuthenticate { [EditorBrowsable (EditorBrowsableState.Never)] public IWebProxy? Proxy { get => null; - set => throw new PlatformNotSupportedException (); + set { + if (value is not null) + throw new PlatformNotSupportedException (); + } } // There doesn't seem to be a trivial way to specify the protocols to accept (or not)