Skip to content

Commit 52e347b

Browse files
committed
[unitytls] UnityTls.IsSupported no longer relies on exception handling but on a simple null check
1 parent 601111c commit 52e347b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void InitializeProviderRegistration ()
228228
providerCache = new Dictionary<Guid,MSI.MonoTlsProvider> ();
229229

230230
#if UNITY
231-
if (Mono.Unity.UnityTls.IsSupported())
231+
if (Mono.Unity.UnityTls.IsSupported)
232232
{
233233
var unityTlsEntry = new Tuple<Guid,String> (UnityTlsId, "Mono.Unity.UnityTlsProvider");
234234
providerRegistration.Add ("default", unityTlsEntry);

mcs/class/System/Mono.UnityTls/UnityTls.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,18 @@ public class mono_unity_unitytls_interface
235235

236236
private static mono_unity_unitytls_interface marshalledInterface = null;
237237

238-
public static bool IsSupported()
239-
{
240-
try {
241-
return NativeInterface != null;
242-
} catch (System.Exception) {
243-
return false;
244-
}
245-
}
238+
public static bool IsSupported => NativeInterface != null;
246239

247240
public static mono_unity_unitytls_interface NativeInterface
248241
{
249242
get
250243
{
251-
if (marshalledInterface == null)
252-
marshalledInterface = Marshal.PtrToStructure<mono_unity_unitytls_interface>(mono_unity_get_unitytls_interface());
244+
if (marshalledInterface == null) {
245+
IntPtr rawInterface = mono_unity_get_unitytls_interface ();
246+
if (rawInterface == IntPtr.Zero)
247+
return null;
248+
marshalledInterface = Marshal.PtrToStructure<mono_unity_unitytls_interface> (rawInterface);
249+
}
253250
return marshalledInterface;
254251
}
255252
}

0 commit comments

Comments
 (0)