C# Record's auto equality comparison
I always thought that when you write a record:
public record MyRecord(int Id, string Name)
{
public string Description { get; set; }
}
The Description property won’t matter for equality because it is mutable. I always thought about records as immutable structures: once declared and put in a collection, their value will not change - and so their equality will not change just because you set a property. So it was very surprising, and it kind of defeats the whole purpose of a record.
Why is it like that?