Don't ask the type loader to build instantiations over generic type definitions#3478
Conversation
| // The reflection stack will use this to construct a Type that doesn't have a type handle. | ||
| // Note: this is different from the validation we do in EnsureSatisfiesClassConstraints because this | ||
| // should not throw. | ||
| if (RuntimeAugments.IsGenericTypeDefinition(genericTypeArgumentHandles[i])) |
There was a problem hiding this comment.
We throw a NotSupportedException when trying to create arrays with a generic type def element. Should we keep the behavior consistent?
There was a problem hiding this comment.
Good point. Seems like that is not the right place to throw the exception either. The CLR allows typeof(List<>).MakeArrayType(); just fine.
We don't know the intent of the higher level caller at this point, so returning false is what the protocol would dictate. It's up to the caller to decide what to do with that.
Cc @atsushikan
There was a problem hiding this comment.
Agreed - this is a low-level method that should return a boolean (or Debug.Assert if truly nonsensical input like a null array) but it shouldn't throw exceptions for "bad input."
Found in CoreFX tests.