From f4b582f654b650b864dac626227c82d505695b51 Mon Sep 17 00:00:00 2001 From: dougbu Date: Fri, 13 Jun 2014 12:53:40 -0700 Subject: [PATCH] Remove incorrect override of `ModelMetadata.GetDisplayName()` - this method delegates to a number of `ModelMetadata` properties - no use cases for overriding; should not be `virtual` - `ModelMetadata.DisplayName` override using `DisplayAttribute.GetName()` coming in next commit --- .../CachedDataAnnotationsModelMetadata.cs | 16 ---------------- .../Metadata/ModelMetadata.cs | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs index 16667c112e..fe0a00c7d9 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs @@ -99,22 +99,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding : base.ComputeShowForEdit(); } - public override string GetDisplayName() - { - // DisplayAttribute doesn't require you to set a name, so this could be null. - if (PrototypeCache.Display != null) - { - var name = PrototypeCache.Display.GetName(); - if (name != null) - { - return name; - } - } - - // If DisplayAttribute does not specify a name, we'll fall back to the property name. - return base.GetDisplayName(); - } - private static void ValidateDisplayColumnAttribute(DisplayColumnAttribute displayColumnAttribute, PropertyInfo displayColumnProperty, Type modelType) { diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/ModelMetadata.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/ModelMetadata.cs index c462570239..8c79d131c9 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/ModelMetadata.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/ModelMetadata.cs @@ -203,7 +203,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding } } - public virtual string GetDisplayName() + public string GetDisplayName() { return PropertyName ?? ModelType.Name; }