diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs index 39a992c8ae..426f515a52 100644 --- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs +++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsMetadataProvider.cs @@ -112,8 +112,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata displayMetadata.IsEnum = true; // IsFlagsEnum - displayMetadata.IsFlagsEnum = - underlyingTypeInfo.GetCustomAttribute(inherit: false) != null; + displayMetadata.IsFlagsEnum = underlyingTypeInfo.IsDefined(typeof(FlagsAttribute), inherit: false); // EnumDisplayNamesAndValues and EnumNamesAndValues // diff --git a/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs b/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs index 80235a3eb1..4cddf6d4ca 100644 --- a/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Formatters.Xml/ModelBinding/DataMemberRequiredBindingMetadataProvider.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata // isDataContract == true iff the container type has at least one DataContractAttribute var containerType = context.Key.ContainerType.GetTypeInfo(); - var isDataContract = containerType.GetCustomAttribute() != null; + var isDataContract = containerType.IsDefined(typeof(DataContractAttribute)); if (isDataContract) { // We don't need to add a validator, just to set IsRequired = true. The validation diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentConventions.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentConventions.cs index a0e459fd41..8227c39d39 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentConventions.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentConventions.cs @@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.ViewComponents return typeInfo.Name.EndsWith(ViewComponentSuffix, StringComparison.OrdinalIgnoreCase) || - typeInfo.GetCustomAttribute() != null; + typeInfo.IsDefined(typeof(ViewComponentAttribute)); } } }