Fix equality check on property group (#13133)

* Fix equality check on property group

Also fix circular reference on PropertyTypeCollection
This commit is contained in:
Dennis
2023-03-22 01:38:10 +02:00
committed by GitHub
parent 36069aa813
commit f64f634979
2 changed files with 3 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ using System.Collections.Specialized;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using Umbraco.Cms.Core.Models.Entities;
namespace Umbraco.Cms.Core.Models;
@@ -132,7 +133,7 @@ public class PropertyGroup : EntityBase, IEquatable<PropertyGroup>
}
public bool Equals(PropertyGroup? other) =>
base.Equals(other) || (other != null && Type == other.Type && Alias == other.Alias);
base.Equals(other) || (other != null && Type == other.Type && Alias == other.Alias && Id == other.Id);
public override int GetHashCode() => (base.GetHashCode(), Type, Alias).GetHashCode();

View File

@@ -30,7 +30,7 @@ public class PropertyTypeCollection : KeyedCollection<string, IPropertyType>, IN
// This baseclass calling is needed, else compiler will complain about nullability
/// <inheritdoc />
public bool IsReadOnly => ((ICollection<IPropertyType>)this).IsReadOnly;
public bool IsReadOnly => false;
// 'new' keyword is required! we can explicitly implement ICollection<IPropertyType>.Add BUT since normally a concrete PropertyType type
// is passed in, the explicit implementation doesn't get called, this ensures it does get called.