diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs index 6e481844c8b63..7e3a11ac3414a 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs @@ -136,7 +136,9 @@ public static int OffsetToStringData [MethodImpl(MethodImplOptions.InternalCall)] public static extern bool TryEnsureSufficientExecutionStack(); - private static unsafe object GetUninitializedObjectInternal(Type type) + private static unsafe object GetUninitializedObjectInternal( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + Type type) { RuntimeType rt = (RuntimeType)type; Debug.Assert(rt != null); diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index 05d97361c89ca..9c8fd22edbe12 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -3999,6 +3999,7 @@ private void Initialize(RuntimeType type) delegate* pfnNewobj = RuntimeTypeHandle.GetNewobjHelperFnPtr(type, out _pMT, unwrapNullable: false, allowCom: true); if (_pMT->IsNullable) { + static object? GetNull(MethodTable* pMT) => null; pfnNewobj = &GetNull; // Activator.CreateInstance(typeof(Nullable)) => null } @@ -4014,8 +4015,6 @@ public void EnsureInitialized(RuntimeType type) Initialize(type); } } - - private static object? GetNull(MethodTable* pMT) => null; } ///