[reflection] mono_method_get_base_method on a GTD should use canonical ginst (mono/mono#17475)
* [test] GetCustomAttributes on generic type definition
* [reflection] mono_method_get_base_method on a GTD should use canonical ginst
The issue is in how we pass along the generic instantiation. So there are two
parts here: we start with a method on a GTD which has to decompose into the GTD
and it's instantiation with its own generic parameters, and then we go up to
its parent and grandparent inflating and decomposing the resulting
instantiation. The instantiations keep passing the last parameter as the number
of parameters shrinks so that the gparam index from the original type is now
out of bounds for the parent and grandparent. If we mess up, we'll get a
BadImageFormatException from the runtime
Fixes https://github.com/mono/mono/issues/17278
Commit migrated from https://github.com/mono/mono/commit/
fb5b2c949ddd2ab09fcddb458584a5facd9ec94e