for get property DisplayName attribute value, ModelMetadataProvider used at .NET Framework versions.
ModelMetadataProviders.Current.GetMetadataForProperty(null, ClassType, PropertyName).DisplayName;
and I tried get DisplayName in .NET 6:
class SampleClass{
[Display(Name = "FirstName", ResourceType = typeof(MyResource))]
public string Name{ get; set; }
}
Type ClassType = typeof(SampleClass);
string PropertyName = "Name";
string displayName = TypeDescriptor.GetProperties(ClassType)
.Cast<PropertyDescriptor>()
.ToDictionary(p => p.Name, p => p.DisplayName)
.FirstOrDefault(p => p.Key == PropertyName).ToString();
The DisplayName value will be received, but the output value does not change when the CultureInfo is changed!