@@ -84,8 +84,8 @@ public T Unbox<T>() where T : unmanaged
84
84
private static readonly Type [ ] _intPtrTypeArray = { typeof ( IntPtr ) } ;
85
85
private static readonly MethodInfo _getUninitializedObject = typeof ( RuntimeHelpers ) . GetMethod ( nameof ( RuntimeHelpers . GetUninitializedObject ) ) ! ;
86
86
private static readonly MethodInfo _getTypeFromHandle = typeof ( Type ) . GetMethod ( nameof ( Type . GetTypeFromHandle ) ) ! ;
87
- private static readonly MethodInfo _createGCHandle = typeof ( Il2CppObjectBase ) . GetMethod ( nameof ( CreateGCHandle ) ) ! ;
88
- private static readonly FieldInfo _isWrapped = typeof ( Il2CppObjectBase ) . GetField ( nameof ( isWrapped ) ) ! ;
87
+ private static readonly MethodInfo _createGCHandle = typeof ( Il2CppObjectBase ) . GetMethod ( nameof ( CreateGCHandle ) , BindingFlags . Instance | BindingFlags . NonPublic ) ! ;
88
+ private static readonly FieldInfo _isWrapped = typeof ( Il2CppObjectBase ) . GetField ( nameof ( isWrapped ) , BindingFlags . Instance | BindingFlags . NonPublic ) ! ;
89
89
90
90
internal static class InitializerStore < T >
91
91
{
@@ -112,7 +112,7 @@ private static Func<IntPtr, T> Create()
112
112
// However, it could be be user-made or implicit
113
113
// In that case we set the GCHandle and then call the ctor and let GC destroy any objects created by DerivedConstructorPointer
114
114
115
- // var obj = (T)FormatterServices .GetUninitializedObject(type);
115
+ // var obj = (T)RuntimeHelpers .GetUninitializedObject(type);
116
116
il . Emit ( OpCodes . Ldtoken , type ) ;
117
117
il . Emit ( OpCodes . Call , _getTypeFromHandle ) ;
118
118
il . Emit ( OpCodes . Call , _getUninitializedObject ) ;
@@ -126,7 +126,7 @@ private static Func<IntPtr, T> Create()
126
126
// obj.isWrapped = true;
127
127
il . Emit ( OpCodes . Dup ) ;
128
128
il . Emit ( OpCodes . Ldc_I4_1 ) ;
129
- il . Emit ( OpCodes . Stsfld , _isWrapped ) ;
129
+ il . Emit ( OpCodes . Stfld , _isWrapped ) ;
130
130
131
131
var parameterlessConstructor = type . GetConstructor ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic , Type . EmptyTypes ) ;
132
132
if ( parameterlessConstructor != null )
0 commit comments