From 36533db58c94bcf9ff632ebed7eda3d38645e5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 22 Jan 2024 06:44:19 +0100 Subject: [PATCH] Work around IsPrimitive compilation issue --- .../System.Private.CoreLib/src/System/Type.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.cs b/src/libraries/System.Private.CoreLib/src/System/Type.cs index 1d798a494047e..17e4636296c17 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.cs @@ -125,7 +125,15 @@ public virtual Type[] GetGenericParameterConstraints() public virtual bool IsEnum { [Intrinsic] get => IsSubclassOf(typeof(Enum)); } public bool IsMarshalByRef => IsMarshalByRefImpl(); protected virtual bool IsMarshalByRefImpl() => false; - public bool IsPrimitive { [Intrinsic] get => IsPrimitiveImpl(); } + public bool IsPrimitive + { +#if NATIVEAOT + // https://github.com/dotnet/runtime/issues/97272 + [MethodImpl(MethodImplOptions.NoOptimization)] +#endif + [Intrinsic] + get => IsPrimitiveImpl(); + } protected abstract bool IsPrimitiveImpl(); public bool IsValueType { [Intrinsic] get => IsValueTypeImpl(); } protected virtual bool IsValueTypeImpl() => IsSubclassOf(typeof(ValueType));