Hi,
I'm using csla 3.6.2.
Recently I came across veery strange issue in my project: it appeared that csla swapped the values of certain properties under some conditions.
After some research I found the source of the problem. Managed properties rely very much on the fact that cached list of properties is sorted in the same way on client and on server.
The sorting is based on PropertyInfo<T> IComparable implementation:
int IComparable.CompareTo(object obj)
{
return _name.CompareTo((Core.IPropertyInfo)obj).Name);
}
To my surprise I found that if CurrentCulture is 'sv-SE' (like it was on client) the following is true:
"vb".CompareTo("wa") == 1
In other cultures (like it was on server):
"vb".CompareTo("wa") == -1 (which makes more sense to me)
What you think about this? I'd say the 'CompareTo' is unreliable.
Thanks.
Hmm... I'm not familar with Swedish, but it looks to me like CompareTo is respecting the culture rules of the language. What is the CurrentCultrure on the server? My guess is that this CompareTo call is occuring before Csla sets the CurrentCulture, so maybe it should be using the InvariantCulture when doing the compare.
Hmmm..
That looks like a bug i PropertyInfo, could you try the following in your PropertyInfo<T> ?
int IComparable.CompareTo(object obj)
{
return string.Compare(_name, ((Core.IPropertyInfo)obj).Name, CultureInfo.InvariantCulture, CompareOptions.None);
}
Yes, that's what I did, thanks.
I'd say it should be fixed in CSLA also.
Copyright (c) Marimer LLC