|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GetCustomAttributes(true) not working when on an overriden PropertI just found out that if i have this code public class A { [MyAttribute()] public virtual int MyInt { get { return 1; } } } public class SubA : A { public override int MyInt { get { return 2; } } } calling GetCustomAttributes(true) on the SubA.MyInt propertyInfo doesnt return the MyAttribute object...and that shouldnt be the case!!! I really is a problem...do you guys have an explenation ...Am I doing something wrong??? Thanks Ok found out on a blog that for PropertyInfo the method doesnt work as
documented... you need to use Attribute.GetCustomAttributes(propertyInfo, true) to get inherited custom attributes... Show quote "Patrick" wrote: > Hello, > > I just found out that if i have this code > > public class A > { > [MyAttribute()] > public virtual int MyInt { get { return 1; } } > } > > public class SubA : A > { > public override int MyInt { get { return 2; } } > } > > calling GetCustomAttributes(true) on the SubA.MyInt propertyInfo doesnt > return the MyAttribute object...and that shouldnt be the case!!! I really is > a problem...do you guys have an explenation ...Am I doing something wrong??? > > Thanks > |
|||||||||||||||||||||||