I’m trying to check if a type has the [DataContract] attribute defined or inherits a type that has it defined
for instance:
[DataContract]
public class Base
{
}
public class Child : Base
{
}
// IsDefined(typeof(Child), typeof(DataContract)) should be true;
the Attribute.IsDefined, and Attribute.GetCustomAttribute doesn’t look at the base class
anybody knows how to do this without looking at the BaseClasses
Try this
I got the idea to make it with a recursive call because of the term “recursion” in your comment. Here is an extension method
call it like this