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

Go one less step when resolving [ModelMetadataType] #2699

Merged
merged 1 commit into from
Jun 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public static ModelAttributes GetAttributesForProperty([NotNull] Type type, [Not
if (metadataProperty != null)
{
propertyAttributes = propertyAttributes.Concat(metadataProperty.GetCustomAttributes());

var propertyMetadataType = metadataProperty.PropertyType;
typeAttributes = typeAttributes.Concat(propertyMetadataType.GetTypeInfo().GetCustomAttributes());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,17 @@ public void GetAttributesForProperty_MergedAttributes()
var attributes = ModelAttributes.GetAttributesForProperty(typeof(MergedAttributes), property);

// Assert
Assert.Equal(4, attributes.Attributes.Count);
Assert.Equal(3, attributes.Attributes.Count);
Assert.IsType<RequiredAttribute>(attributes.Attributes[0]);
Assert.IsType<RangeAttribute>(attributes.Attributes[1]);
Assert.IsType<ClassValidator>(attributes.Attributes[2]);
Assert.IsType<BindAttribute>(attributes.Attributes[3]);

Assert.Equal(2, attributes.PropertyAttributes.Count);
Assert.IsType<RequiredAttribute>(attributes.PropertyAttributes[0]);
Assert.IsType<RangeAttribute>(attributes.PropertyAttributes[1]);

Assert.Equal(2, attributes.TypeAttributes.Count);
Assert.IsType<ClassValidator>(attributes.TypeAttributes[0]);
Assert.IsType<BindAttribute>(attributes.TypeAttributes[1]);
var attribute = Assert.Single(attributes.TypeAttributes);
Assert.IsType<ClassValidator>(attribute);
}

[ClassValidator]
Expand Down Expand Up @@ -207,7 +205,7 @@ private class DerivedModel : BaseModel

[Range(10,100)]
public override int VirtualProperty { get; set; }

}

[ModelMetadataType(typeof(BaseModel))]
Expand Down