diff --git a/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs b/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs
index 9d02372926acd0..0b3e7529f4ca70 100644
--- a/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs
+++ b/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs
@@ -404,9 +404,13 @@ public async Task Number_AsCollectionElement_RoundTrip()
await RunAsCollectionElementTest(JsonNumberTestData.NullableDoubles);
await RunAsCollectionElementTest(JsonNumberTestData.NullableDecimals);
#if NET
- await RunAsCollectionElementTest(JsonNumberTestData.NullableInt128s);
- await RunAsCollectionElementTest(JsonNumberTestData.NullableUInt128s);
- await RunAsCollectionElementTest(JsonNumberTestData.NullableHalfs);
+ // https://github.com/dotnet/runtime/issues/119143
+ if (!PlatformDetection.IsBrowser)
+ {
+ await RunAsCollectionElementTest(JsonNumberTestData.NullableInt128s);
+ await RunAsCollectionElementTest(JsonNumberTestData.NullableUInt128s);
+ await RunAsCollectionElementTest(JsonNumberTestData.NullableHalfs);
+ }
#endif
}
}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/ILLink.Descriptors.xml b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/ILLink.Descriptors.xml
index 2c692431c3ac27..1842a29b1b00c3 100644
--- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/ILLink.Descriptors.xml
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/ILLink.Descriptors.xml
@@ -3,6 +3,8 @@
+
+
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj
index f69d73da47c723..530620846c553b 100644
--- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj
@@ -26,6 +26,7 @@
1
+ true
diff --git a/src/mono/mono/metadata/class-accessors.c b/src/mono/mono/metadata/class-accessors.c
index c71a5073fafe7f..1a64e859399228 100644
--- a/src/mono/mono/metadata/class-accessors.c
+++ b/src/mono/mono/metadata/class-accessors.c
@@ -569,6 +569,23 @@ mono_class_set_failure (MonoClass *klass, MonoErrorBoxed *boxed_error)
return TRUE;
}
+/**
+ * mono_class_set_skip_generic_constraints:
+ * \param klass class that should not validate generic constraints
+ *
+ * LOCKING: Acquires the loader lock.
+ */
+void
+mono_class_set_skip_generic_constraints (MonoClass *klass)
+{
+ if (klass->skip_generic_constraints)
+ return;
+
+ mono_loader_lock ();
+ klass->skip_generic_constraints = 1;
+ mono_loader_unlock ();
+}
+
/**
* mono_class_set_deferred_failure:
* \param klass class in which the failure was detected
diff --git a/src/mono/mono/metadata/class-init.c b/src/mono/mono/metadata/class-init.c
index 52f108fc7cc9a0..acdd4404c5272a 100644
--- a/src/mono/mono/metadata/class-init.c
+++ b/src/mono/mono/metadata/class-init.c
@@ -2613,10 +2613,12 @@ mono_class_layout_fields (MonoClass *klass, int base_instance_size, int packing_
case MONO_TYPE_TYPEDBYREF:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_GENERICINST:
- field_class = mono_class_from_mono_type_internal (field->type);
- if (mono_class_is_ginst (field_class) && !mono_verifier_class_is_valid_generic_instantiation (field_class)) {
- mono_class_set_type_load_failure (klass, "Field '%s' is an invalid generic instantiation of type %s", field->name, mono_type_get_full_name (field_class));
- return;
+ if (!klass->skip_generic_constraints) {
+ field_class = mono_class_from_mono_type_internal (field->type);
+ if (mono_class_is_ginst (field_class) && !mono_verifier_class_is_valid_generic_instantiation (field_class)) {
+ mono_class_set_type_load_failure (klass, "Field '%s' is an invalid generic instantiation of type %s", field->name, mono_type_get_full_name (field_class));
+ return;
+ }
}
break;
default:
@@ -3202,7 +3204,7 @@ mono_class_init_internal (MonoClass *klass)
mono_class_setup_interface_offsets_internal (klass, first_iface_slot, MONO_SETUP_ITF_OFFSETS_OVERWRITE);
- if (mono_class_is_ginst (klass) && !mono_verifier_class_is_valid_generic_instantiation (klass))
+ if (!klass->skip_generic_constraints && mono_class_is_ginst (klass) && !mono_verifier_class_is_valid_generic_instantiation (klass))
mono_class_set_type_load_failure (klass, "Invalid generic instantiation");
goto leave;
diff --git a/src/mono/mono/metadata/class-internals.h b/src/mono/mono/metadata/class-internals.h
index ba56a62ad6b818..9c2c74161b9d34 100644
--- a/src/mono/mono/metadata/class-internals.h
+++ b/src/mono/mono/metadata/class-internals.h
@@ -1418,6 +1418,9 @@ mono_class_find_enum_basetype (MonoClass *klass, MonoError *error);
gboolean
mono_class_set_failure (MonoClass *klass, MonoErrorBoxed *boxed_error);
+void
+mono_class_set_skip_generic_constraints (MonoClass *klass);
+
void
mono_class_set_deferred_failure (MonoClass *klass);
diff --git a/src/mono/mono/metadata/class-private-definition.h b/src/mono/mono/metadata/class-private-definition.h
index 005cd05935067e..b8c66cdb7a97f3 100644
--- a/src/mono/mono/metadata/class-private-definition.h
+++ b/src/mono/mono/metadata/class-private-definition.h
@@ -81,6 +81,7 @@ struct _MonoClass {
/* next byte*/
guint is_exception_class : 1; /* is System.Exception or derived from it */
guint variant_search_table_inited : 1;
+ guint skip_generic_constraints : 1; /* type created for AOT wrapper methods, which don't need to comply with generic constraints */
MonoClass *parent;
MonoClass *nested_in;
diff --git a/src/mono/mono/mini/mini-generic-sharing.c b/src/mono/mono/mini/mini-generic-sharing.c
index 11df39a80f664c..8ae3d2cc42006e 100644
--- a/src/mono/mono/mini/mini-generic-sharing.c
+++ b/src/mono/mono/mini/mini-generic-sharing.c
@@ -1321,7 +1321,7 @@ get_wrapper_shared_vtype (MonoType *t)
}
/*
- * get_wrapper_shared_type:
+ * get_wrapper_shared_type_full:
*
* Return a type which is handled identically wrt to calling conventions as T.
*/
@@ -1415,6 +1415,8 @@ get_wrapper_shared_type_full (MonoType *t, gboolean is_field)
mono_error_assert_ok (error); /* FIXME don't swallow the error */
g_assert (klass);
+ mono_class_set_skip_generic_constraints (klass);
+
t = m_class_get_byval_arg (klass);
MonoType *shared_type = get_wrapper_shared_vtype (t);
if (shared_type)