From: Igor K. (JIRA) <nh...@gm...> - 2011-04-08 18:11:50
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Igor Krupin updated NH-2637: ---------------------------- Attachment: Capture.PNG > NHibernate.Properties.BasicPropertyAccessor.GetSetterOrNull is case sensitive > ----------------------------------------------------------------------------- > > Key: NH-2637 > URL: http://216.121.112.228/browse/NH-2637 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.1.0 > Reporter: Igor Krupin > Priority: Major > Attachments: Capture.PNG > > > We are running NH 2.1 and discovered this bug trying to upgrade to NH 3.1. We do a lot of AliasToBean stuff, mapping tables to DTOs, and AliasToBean will call this method to get the properties. Problem is, it's case sensitive now! Reading code comments i see this: > ============ <CODE SNIPPET> ================ > BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; > if (type.IsValueType) > { > // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does > // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly > // stating that casing should be ignored so we get the same behavior for both structs and classes > bindingFlags = bindingFlags | BindingFlags.IgnoreCase; > } > ============ </CODE SNIPPET> ================ > "If type is a class, it _does_ ignore case..." -- incorrect. By default in classes case will _not_ be ignored, you explicitly have to specify it using a flag, same as you do for value type. > The fix for this is rather simple, just add the BindingFlags.IgnoreCase flag and all's good. No need for the "if (type.IsValueType)" anymore either. GetGetterOrNull suffers from the same. > Thank You!!! > Igor -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |