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

Should we handle [ModelMetadataType] on a property's Type? #2403

Closed
dougbu opened this issue Apr 17, 2015 · 3 comments
Closed

Should we handle [ModelMetadataType] on a property's Type? #2403

dougbu opened this issue Apr 17, 2015 · 3 comments

Comments

@dougbu
Copy link
Member

dougbu commented Apr 17, 2015

Currently GetMetadataForType() includes the given Type's metadata as well as that provided by the Type referenced in an associated [ModelMetadataType] (if any). Similarly GetMetadataForProperty() includes the given property's metadata, that provided by the Type referenced in a [ModelMetadataType] associated with the property (if any), and the property's Type. However GetMetadataForProperty() does not include metadata from a Type referenced in a [ModelMetadataType] associated with the property's Type. Need to check MVC 5 behaviour for this case and do the Right Thing:tm: to maintain compatibility.

@danroth27
Copy link
Member

@kirthik Please verify what the MVC 5 behavior was with [MetadataType] and align our behavior if needed.

@Eilon Eilon assigned dougbu and unassigned kirthik Apr 22, 2015
@Eilon
Copy link
Member

Eilon commented Apr 22, 2015

Moving to @dougbu to verify the behavior in MVC 5.

@Eilon Eilon modified the milestones: 6.0.0-beta6, 6.0.0-beta5 May 18, 2015
@dougbu
Copy link
Member Author

dougbu commented May 26, 2015

Behaviour w.r.t. [MetadataType] or [ModelMetadataType] on a property's Type in MVC 5 and 6 is consistent: Neither version brings information in from AnotherType in the example below i.e. the only visible validators are PropertyTypeValidatorAttribute and the adapter for RequiredAttribute.

    public class MergedAttributes
    {
        [Required]
        public PropertyType Property { get; set; }
    }

    [PropertyTypeValidator]
    [MetadataType(typeof(AnotherType))]
    public class PropertyType
    {
    }

    // Not seen when using MVC 5 or 6.
    [AnotherTypeValidator]
    [HiddenInput]
    public class AnotherType
    {
    }

However the two versions are inconsistent in a different way. Will open a new bug for that inconsistency.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants