I have come accross a behavior of RealmObject which I absolutely don’t understand. I am persisting emails in Realm. These RealmObjects have a property called IsRead:
public partial class Email : RealmObject
{
[PrimaryKey]
public ObjectId Id { get; set; }
[Indexed]
public bool IsRead { get; set; }
....
}
The second screenshot where dowey == 1000 is evaluated as false, you have dowey = 100 (one less zero) in the if case. That seems fixed in the 3rd screenshot, but it’s not clear whether the debugger evaluates dowey == 1000 to false.
That looks like either an intellisense/debugger issue or something very suspiciously wrong. Can you instead try adding Console.WriteLine statement for email.IsRead at the start of the function.
Value from local: True
Value from object: True
Dowey: 0
[um.denomail.ap] Explicit concurrent copying GC freed 28373(1458KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 4305KB/8610KB, paused 307us total 8.065ms
Value from local: True
Value from object: True
Dowey: 0
Value from local: False
Value from object: False
Dowey: 1000
→ The value on IntelliSense is always false
I can therefore confirm that the issue materializes in IntelliSense, but the cause seems to be in the ReallmObject:
if I replace the realm object with a POCO, IntelliSense works properly
the property is an auto-property, but RealmObject must do sth in order to intercept it (so that it can raise the exception on setters-outside-of-write). This something seems then to confuse IntelliSense.
It’s likely the debugger trying to be clever and using the field value rather than the property itself. There’s little we can do to fix that with the current approach where we use IL weaving to replace the getter/setter of RealmObject properties. This will probably be alleviated once we switch to source generators.