Skip to content

Commit be1ef91

Browse files
Remove Assert in Method.MakeGeneric on Invalid Arg (#116788)
The call to mono_class_inflate_generic_method_checked will set error when there are invalid types (e.g. typeof(void)/typeof(int*)) passed in. This should not be an assert, it should fall to the "Invalid generic arguments" message below. This does lose the error returned by mono_class_inflate_generic_method_checked but that error isn't user friendly. It would report be something like: "MVAR 1 cannot be expanded with type 0x1" Instead report the more readable error to the user. Fix: 71339
1 parent 3286149 commit be1ef91

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/mono/mono/metadata/reflection.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,9 +2728,8 @@ reflection_bind_generic_method_parameters (MonoMethod *method, MonoArrayHandle t
27282728
tmp_context.method_inst = ginst;
27292729

27302730
inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, error);
2731-
mono_error_assert_ok (error);
27322731

2733-
if (!mono_verifier_is_method_valid_generic_instantiation (inflated)) {
2732+
if (!is_ok(error) || !inflated || !mono_verifier_is_method_valid_generic_instantiation (inflated)) {
27342733
mono_error_set_argument (error, NULL, "Invalid generic arguments");
27352734
return NULL;
27362735
}

0 commit comments

Comments
 (0)