private bool HasAnyErrors(IList<Type> types)
{
bool anyErrors = false;
foreach (var type in types)
{
var classAttributes = type.GetCustomAttributes(false);
if (classAttributes.All(attr => attr.GetType().Name != "DataContractAttribute"))
{
Console.WriteLine("Classs {0} has no DataContractAttribute", type.Name);
anyErrors = true;
}
if (classAttributes.All(attr => attr.GetType().Name != "SerializableAttribute"))
{
Console.WriteLine("Classs {0} has no SerializableAttribute", type.Name);
anyErrors = true;
}
var properties = type.GetProperties();
foreach (var property in properties)
{
var propertyAttributes = property.GetCustomAttributes(false);
if (!propertyAttributes.Any(attr => attr.GetType().Name == "DataMemberAttribute") && !propertyAttributes.Any(attr => attr.GetType().Name == "DataMemberIgnoreAttribute"))
{
Console.WriteLine("Property {0}.{1} has no DataMemberAttribute", type.Name, property.Name);
anyErrors = true;
}
}
}
return anyErrors;
}
}