diff --git a/eng/testing/tests.singlefile.targets b/eng/testing/tests.singlefile.targets
index 9c5585602da775..233db988324e90 100644
--- a/eng/testing/tests.singlefile.targets
+++ b/eng/testing/tests.singlefile.targets
@@ -50,10 +50,6 @@
-
-
-
-
diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ExecutionEnvironment.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ExecutionEnvironment.cs
index b990dac4712ebb..1045f76bf927b9 100644
--- a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ExecutionEnvironment.cs
+++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ExecutionEnvironment.cs
@@ -53,7 +53,8 @@ public abstract class ExecutionEnvironment
//==============================================================================================
// Invoke and field access support.
//==============================================================================================
- public abstract MethodBaseInvoker TryGetMethodInvoker(RuntimeTypeHandle declaringTypeHandle, QMethodDefinition methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles);
+ public abstract void ValidateGenericMethodConstraints(MethodInfo method);
+ public abstract MethodBaseInvoker TryGetMethodInvokerNoConstraintCheck(RuntimeTypeHandle declaringTypeHandle, QMethodDefinition methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles);
public abstract FieldAccessor TryGetFieldAccessor(MetadataReader reader, RuntimeTypeHandle declaringTypeHandle, RuntimeTypeHandle fieldTypeHandle, FieldHandle fieldHandle);
//==============================================================================================
@@ -108,7 +109,7 @@ internal MethodBaseInvoker GetMethodInvoker(RuntimeTypeInfo declaringType, QMeth
{
genericMethodTypeArgumentHandles[i] = genericMethodTypeArguments[i].TypeHandle;
}
- MethodBaseInvoker methodInvoker = TryGetMethodInvoker(typeDefinitionHandle, methodHandle, genericMethodTypeArgumentHandles);
+ MethodBaseInvoker methodInvoker = TryGetMethodInvokerNoConstraintCheck(typeDefinitionHandle, methodHandle, genericMethodTypeArgumentHandles);
if (methodInvoker == null)
exception = ReflectionCoreExecution.ExecutionEnvironment.CreateNonInvokabilityException(exceptionPertainant);
return methodInvoker;
diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
index 6fb23a261f3337..d592f7506f7aec 100644
--- a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
+++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
@@ -26,6 +26,7 @@
using System.Runtime.InteropServices;
using System.Threading;
+using Internal.Reflection.Core.Execution;
using Internal.Runtime.CompilerHelpers;
using Internal.Runtime.CompilerServices;
@@ -70,6 +71,20 @@ public static object RawNewObject(RuntimeTypeHandle typeHandle)
return RuntimeImports.RhNewObject(typeHandle.ToMethodTable());
}
+ internal static void EnsureMethodTableSafeToAllocate(MethodTable* mt)
+ {
+ // We might be dealing with a "necessary" MethodTable (in the ILCompiler terms).
+ // This MethodTable is okay for casting, but must not be allocated on the GC heap.
+ Debug.Assert(MethodTable.Of