Rename ModelMetadata.IsCollectionType
; perhaps provide real IsCollectionType
as well?? #3022
Description
The ModelMetadata.IsCollectionType
property actually checks whether ModelType
implements IEnumerable
. Since this property is new in MVC 6, we could rename it to match the actual meaning -- IsEnumerableType
.
Product code uses ClosedGenericMatcher.ExtractGenericInterface()
to find T
for ICollection<T>
in a few places where ModelMetadata
is available. These cases could be handled using ModelMetadata.ElementMetadata
and a "real" ModelMetadata.IsCollectionType
or ModelMetadata.IsGenericCollectionType
.
Final step along these lines would be to add ModelMetadata.TaskTypeParameter
or ModelMetadata.TaskTypeParameterMetadata
. This could replace uses of ClosedGenericMatcher.ExtractGenericInterface()
to find T
for Task<T>
-- another repeated gesture.
These changes would make ModelMetadata
more usable and broadly useful. Would also avoid lower-level helper methods and repeated code -- in our code and in customer code.