@@ -25,6 +25,8 @@ Jeroen Frijters
25
25
using System . Reflection ;
26
26
#if ! NO_REF_EMIT
27
27
using System . Reflection . Emit ;
28
+ using System . Runtime . CompilerServices ;
29
+
28
30
#endif
29
31
using System . Runtime . Serialization ;
30
32
using System . Security ;
@@ -282,7 +284,11 @@ internal SerializationConstructorAccessorImpl(global::java.lang.reflect.Construc
282
284
[ SecuritySafeCritical ]
283
285
public object newInstance ( object [ ] args )
284
286
{
287
+ #if NETFRAMEWORK
285
288
var obj = FormatterServices . GetUninitializedObject ( type ) ;
289
+ #else
290
+ var obj = RuntimeHelpers . GetUninitializedObject ( type ) ;
291
+ #endif
286
292
if ( mw != null )
287
293
mw . Invoke ( obj , ConvertArgs ( mw . DeclaringType . GetClassLoader ( ) , mw . GetParameters ( ) , args ) ) ;
288
294
@@ -966,13 +972,17 @@ public object newInstance(object[] args)
966
972
967
973
}
968
974
969
- private sealed class FastSerializationConstructorAccessorImpl : global ::sun . reflect . ConstructorAccessor
975
+ sealed class FastSerializationConstructorAccessorImpl : global ::sun . reflect . ConstructorAccessor
970
976
{
971
977
972
- private static readonly MethodInfo GetTypeFromHandleMethod = typeof ( Type ) . GetMethod ( "GetTypeFromHandle" , new Type [ ] { typeof ( RuntimeTypeHandle ) } ) ;
973
- private static readonly MethodInfo GetUninitializedObjectMethod = typeof ( FormatterServices ) . GetMethod ( "GetUninitializedObject" , new Type [ ] { typeof ( Type ) } ) ;
974
- private delegate object InvokeCtor ( ) ;
975
- private InvokeCtor invoker ;
978
+ static readonly MethodInfo GetTypeFromHandleMethod = typeof ( Type ) . GetMethod ( nameof ( Type . GetTypeFromHandle ) , new [ ] { typeof ( RuntimeTypeHandle ) } ) ;
979
+ #if NETFRAMEWORK
980
+ static readonly MethodInfo GetUninitializedObjectMethod = typeof ( FormatterServices ) . GetMethod ( nameof ( FormatterServices . GetUninitializedObject ) , new [ ] { typeof ( Type ) } ) ;
981
+ #else
982
+ static readonly MethodInfo GetUninitializedObjectMethod = typeof ( RuntimeHelpers ) . GetMethod ( nameof ( RuntimeHelpers . GetUninitializedObject ) , new [ ] { typeof ( Type ) } ) ;
983
+ #endif
984
+ delegate object InvokeCtor ( ) ;
985
+ InvokeCtor invoker ;
976
986
977
987
internal FastSerializationConstructorAccessorImpl ( global ::java . lang . reflect . Constructor constructorToCall , global ::java . lang . Class classToInstantiate )
978
988
{
0 commit comments