From d7eb567085991e5ec81bbf3e65b8764811acfc78 Mon Sep 17 00:00:00 2001 From: VS MobileTools Engineering Service 2 Date: Mon, 2 Sep 2024 07:35:41 -0700 Subject: [PATCH] [release/8.0.1xx-xcode15.4] [Foundation] Allow setting NSUrlSessionHandler.Proxy to null (#21147) 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 Backport of #21140 --- 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)