-
Notifications
You must be signed in to change notification settings - Fork 3
Description
reproducible:
Use DataAnnotation for example in a WPF Project.
The Method ValidateProperties will always return true, because the linq query result is empty.
var propertiesToValidate = _entityToValidate.GetType()
.GetRuntimeProperties()
.Where(c => c.GetCustomAttributes(typeof(ValidationAttribute)).Any());
Because the type of the DataAnnotation from the wpf project differs from the type typeof(ValidationAttribute)
of the PCL project which are not equal:
wpf type
_entityToValidate.GetType().GetRuntimeProperties().ElementAt(1).GetCustomAttributes().FirstOrDefault().GetType().AssemblyQualifiedName
= "System.ComponentModel.DataAnnotations.RequiredAttribute, System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
pcl type
typeof(ValidationAttribute).AssemblyQualifiedName
= System.ComponentModel.DataAnnotations.ValidationAttribute, Portable.DataAnnotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6f21be3d5ccff8cd
Possible solution: Type comparison using Strings (e.g. Type.Name)