runtime: PropertyDescriptor - MemberDescriptor.Attributes returns base attribute instead of ancestor's attribute

“prop.Description” returns “A” instead of “B”

static void Main(string[] args) {
    var prop = (DescriptionAttribute)TypeDescriptor.GetProperties(typeof(B))["Value"].Attributes[typeof(DescriptionAttribute)];
    Assert.Equal("B", prop.Description);
}
class A {
    [Description("A")]
    public virtual int Value { get; set; }
}
class B : A {
    [Description("B")]
    public override int Value { get; set; }
}

[EDIT] Add C# syntax highlighing & change code formatting by @karelz

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

This is not Reflection code. TypeDescriptor is from System.ComponentModel.TypeConverter.dll.