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
- PropertyDescriptor - MemberDescriptor.Attributes returns base attribute instead of ancestor's attribute #26600 — committed to k0st1x/corefx by deleted user 6 years ago
- PropertyDescriptor - MemberDescriptor.Attributes returns base attribute instead of ancestor's attribute #26600 — committed to k0st1x/corefx by k0st1x 6 years ago
- PropertyDescriptor - MemberDescriptor.Attributes returns base attribute instead of ancestor's attribute #26600 — committed to k0st1x/corefx by k0st1x 6 years ago
- PropertyDescriptor - MemberDescriptor.Attributes (iteration 2) (#26756) * PropertyDescriptor - MemberDescriptor.Attributes returns base attribute instead of ancestor's attribute #26600 * Property... — committed to dotnet/corefx by k0st1x 6 years ago
This is not Reflection code.
TypeDescriptor
is fromSystem.ComponentModel.TypeConverter.dll
.