Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.ComponentModel.DataAnnotations works only in PCL #4

Closed
mfe- opened this issue Jul 26, 2016 · 2 comments
Closed

System.ComponentModel.DataAnnotations works only in PCL #4

mfe- opened this issue Jul 26, 2016 · 2 comments
Labels

Comments

@mfe-
Copy link
Owner

mfe- commented Jul 26, 2016

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)

@mfe- mfe- added the bug label Jul 26, 2016
@mfe-
Copy link
Owner Author

mfe- commented Nov 27, 2016

Changed Type to String comparison . Anyway validation evaluates to true. Needs to be more investigated.

@mfe-
Copy link
Owner Author

mfe- commented Nov 30, 2016

Fixed with b2f5c53

@mfe- mfe- closed this as completed Nov 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant