Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

Commented Unassigned: A class inherited from DisplayNameAttribute is not used [7152]

$
0
0
I have inherited a class from System.ComponentModel.DisplayNameAttribute. When I add the attribute for property, the property's attribute is not used by FV. I see from the source code that it uses hard-coded class name. See FluentValidation.ValidatorOptions private static string GetDisplayName(MemberInfo member). IMO it should accept any class that can be assigned to typeof(System.ComponentModel.DisplayNameAttribute).

For now I have fixed the problem by giving the class name DisplayNameAttribute (which lives in my namespace).
Comments: Thanks for the suggestion. Originally, FluentValidation did indeed use typeof(DisplayNameAttribute).IsAssignableFrom(), but this had to be changed as doing this with the version of DataAnnotations that was shipped just after .NET 3.5 caused a runtime exception in some situations. However, as FluentValidation no longer supports .net 3.5 this should be safe to change back. I'll get this changed in the next build. Jeremy

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>