diff --git a/src/runtime/converter.cs b/src/runtime/converter.cs index 2b92ca994..734422ed0 100644 --- a/src/runtime/converter.cs +++ b/src/runtime/converter.cs @@ -113,6 +113,23 @@ internal static IntPtr ToPython(T value) return ToPython(value, typeof(T)); } + private static readonly Func IsTransparentProxy = GetIsTransparentProxy(); + + private static bool Never(object _) => false; + + private static Func GetIsTransparentProxy() + { + var remoting = typeof(int).Assembly.GetType("System.Runtime.Remoting.RemotingServices"); + if (remoting is null) return Never; + + var isProxy = remoting.GetMethod("IsTransparentProxy", new[] { typeof(object) }); + if (isProxy is null) return Never; + + return (Func)Delegate.CreateDelegate( + typeof(Func), isProxy, + throwOnBindFailure: true); + } + internal static IntPtr ToPython(object value, Type type) { if (value is PyObject) @@ -162,15 +179,8 @@ internal static IntPtr ToPython(object value, Type type) var pyderived = value as IPythonDerivedType; if (null != pyderived) { - #if NETSTANDARD - return ClassDerivedObject.ToPython(pyderived); - #else - // if object is remote don't do this - if (!System.Runtime.Remoting.RemotingServices.IsTransparentProxy(pyderived)) - { + if (!IsTransparentProxy(pyderived)) return ClassDerivedObject.ToPython(pyderived); - } - #endif } // hmm - from Python, we almost never care what the declared pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy