Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7a9dcfa

Browse files
authored
reimplement remoting check with .NET standard-compatible reflection (#1170)
1 parentec424bb commit7a9dcfa

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

‎src/runtime/converter.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ internal static IntPtr ToPython<T>(T value)
113113
returnToPython(value,typeof(T));
114114
}
115115

116+
privatestaticreadonlyFunc<object,bool>IsTransparentProxy=GetIsTransparentProxy();
117+
118+
privatestaticboolNever(object_)=>false;
119+
120+
privatestaticFunc<object,bool>GetIsTransparentProxy()
121+
{
122+
varremoting=typeof(int).Assembly.GetType("System.Runtime.Remoting.RemotingServices");
123+
if(remotingisnull)returnNever;
124+
125+
varisProxy=remoting.GetMethod("IsTransparentProxy",new[]{typeof(object)});
126+
if(isProxyisnull)returnNever;
127+
128+
return(Func<object,bool>)Delegate.CreateDelegate(
129+
typeof(Func<object,bool>),isProxy,
130+
throwOnBindFailure:true);
131+
}
132+
116133
internalstaticIntPtrToPython(objectvalue,Typetype)
117134
{
118135
if(valueisPyObject)
@@ -162,15 +179,8 @@ internal static IntPtr ToPython(object value, Type type)
162179
varpyderived=valueasIPythonDerivedType;
163180
if(null!=pyderived)
164181
{
165-
#ifNETSTANDARD
166-
returnClassDerivedObject.ToPython(pyderived);
167-
#else
168-
// if object is remote don't do this
169-
if(!System.Runtime.Remoting.RemotingServices.IsTransparentProxy(pyderived))
170-
{
182+
if(!IsTransparentProxy(pyderived))
171183
returnClassDerivedObject.ToPython(pyderived);
172-
}
173-
#endif
174184
}
175185

176186
// hmm - from Python, we almost never care what the declared

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp