Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Rename ModelMetadata.IsCollectionType; perhaps provide real IsCollectionType as well?? #3022

Closed
@dougbu

Description

@dougbu

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions