From ece2e2359e66f12d7fd380c73f0cbd21eb2c8288 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Apr 2015 11:31:14 +1000 Subject: [PATCH] Updates PropertyGroup's equality comparisons to: check the base comparison, then check for a case insensitive comparison with name, fixes GetHashCode to be consistent with the Equals method. --- src/Umbraco.Core/Models/PropertyGroup.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Core/Models/PropertyGroup.cs b/src/Umbraco.Core/Models/PropertyGroup.cs index 35ddb6ac99..94e46e1ed1 100644 --- a/src/Umbraco.Core/Models/PropertyGroup.cs +++ b/src/Umbraco.Core/Models/PropertyGroup.cs @@ -120,27 +120,22 @@ namespace Umbraco.Core.Models public bool Equals(PropertyGroup other) { - //Check whether the compared object is null. - if (Object.ReferenceEquals(other, null)) return false; - - //Check whether the compared object references the same data. - if (Object.ReferenceEquals(this, other)) return true; + if (base.Equals(other)) return true; //Check whether the PropertyGroup's properties are equal. - return Id.Equals(other.Id) && Name.Equals(other.Name); + return Name.InvariantEquals(other.Name); } public override int GetHashCode() { - //Get hash code for the Name field if it is not null. - int hashName = Name == null ? 0 : Name.GetHashCode(); + int baseHash = base.GetHashCode(); - //Get hash code for the Id field. - int hashId = Id.GetHashCode(); + //Get hash code for the Alias field. + int nameHash = Name.ToLowerInvariant().GetHashCode(); //Calculate the hash code for the product. - return hashName ^ hashId; + return baseHash ^ nameHash; } }