It is really weird. My code is doing a lot of reflection to generate the values that do not work properly. This is in iOS, but may be present in android as well.
I am building a Xaml implementation in a portable class library. I parse the Xaml and generate the appropriate instances. Where I seem to be running into the biggest problems are with my bindings. I do a comparison something like so:
var sourceValue = SourcePropertyInfo.GetValue(Source);
var targetValue = TargetPropertyInfo.GetValue(Target);
if (sourceValue != targetValue)
SourcePropertyInfo.SetValue(Source, TargetPropertyInfo.GetValue(Target));
I haven't experienced the problem on any classes (reference types), but have experienced it on enums, doubles, and structs (value types).
An example with an enum doing it was my implementation of HorizontalAlignment. Both sourceValue and targetValue were equal to HorizontalAlignment.Left, but the != operator returned false, I also tested the other various operators. Casting sourceValue and target value to HorizontalAlignment seemed to solve it as well as casting them to int.
With structs, I found that it would not utilize my implementations of the ==, !=, Equals, and GetHashCode. My Thickness struct had this problem. I put breakpoints on my implementations of ==, etc. and they were never hit. Converting it from a struct to a class and everything worked.
With doubles, this is occurring when comparing double.NaN.
Some of the time it appears that these problems only seem to happen when debugging as well. For example the issue with double.NaN above seems to not happen when running without debugging.
Does anyone have any ideas?
Thanks
Scott HEllewell