You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System;using System.Text;using System.Runtime.CompilerServices;publicclassC{structS{publicinta;publicstringb;};publicstaticvoidMain(){varb1=42.ToString();varb2=42.ToString();vars1=new S {a=42,b=b1};vars2=new S {a=42,b=b2};
Console.WriteLine(object.ReferenceEquals(b1, b2));
Console.WriteLine(s1.Equals(s2));
Console.WriteLine(RuntimeHelpers.Equals(s1, s2));}}
prints
False
True
False
on CoreCLR.
On Mono it prints
False
True
True
The difference is in how ValueTypes are treated by RuntimeHelpers.Equals. CoreCLR does memcmp of the contents, Mono does field-by-field comparison. Which one is right and which one is wrong?
The text was updated successfully, but these errors were encountered:
is there any incentive to get this fixed and align the behavior?
Aligning the behavior between CoreCLR and Mono sounds good to me.
Also, the documentation for the API is wrong. It says "true if the o1 parameter is the same instance as the o2 parameter, or if both are null, or if o1.Equals(o2) returns true; otherwise, false.". This description does not match neither CoreCLR nor Mono implementations.
The following program:
prints
on CoreCLR.
On Mono it prints
The difference is in how ValueTypes are treated by
RuntimeHelpers.Equals
. CoreCLR doesmemcmp
of the contents, Mono does field-by-field comparison. Which one is right and which one is wrong?The text was updated successfully, but these errors were encountered: