diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs index a3d5803ab0..0e2f0feada 100644 --- a/src/Avalonia.Base/AvaloniaObject.cs +++ b/src/Avalonia.Base/AvaloniaObject.cs @@ -163,6 +163,37 @@ namespace Avalonia SetValue(property, AvaloniaProperty.UnsetValue); } + /// + /// Compares two objects using reference equality. + /// + /// The object to compare. + /// + /// Overriding Equals and GetHashCode on an AvaloniaObject is disallowed for two reasons: + /// + /// - AvaloniaObjects are by their nature mutable + /// - The presence of attached properties means that the semantics of equality are + /// difficult to define + /// + /// See https://github.com/AvaloniaUI/Avalonia/pull/2747 for the discussion that prompted + /// this. + /// + public sealed override bool Equals(object obj) => base.Equals(obj); + + /// + /// Gets the hash code for the object. + /// + /// + /// Overriding Equals and GetHashCode on an AvaloniaObject is disallowed for two reasons: + /// + /// - AvaloniaObjects are by their nature mutable + /// - The presence of attached properties means that the semantics of equality are + /// difficult to define + /// + /// See https://github.com/AvaloniaUI/Avalonia/pull/2747 for the discussion that prompted + /// this. + /// + public sealed override int GetHashCode() => base.GetHashCode(); + /// /// Gets a value. ///