From 7208f591c7f03237a6714dd2acdac734c022b9ff Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 22 Mar 2023 01:38:10 +0200 Subject: [PATCH] Fix equality check on property group (#13133) * Fix equality check on property group Also fix circular reference on PropertyTypeCollection (cherry picked from commit f64f6349795279f0e778139ce7e81dcc9827bdc2) --- src/Umbraco.Core/Models/PropertyGroup.cs | 3 ++- src/Umbraco.Core/Models/PropertyTypeCollection.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Models/PropertyGroup.cs b/src/Umbraco.Core/Models/PropertyGroup.cs index 034770cdfc..9d23c85a9b 100644 --- a/src/Umbraco.Core/Models/PropertyGroup.cs +++ b/src/Umbraco.Core/Models/PropertyGroup.cs @@ -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 } 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(); diff --git a/src/Umbraco.Core/Models/PropertyTypeCollection.cs b/src/Umbraco.Core/Models/PropertyTypeCollection.cs index 49c83b4c9d..77a5d84421 100644 --- a/src/Umbraco.Core/Models/PropertyTypeCollection.cs +++ b/src/Umbraco.Core/Models/PropertyTypeCollection.cs @@ -30,7 +30,7 @@ public class PropertyTypeCollection : KeyedCollection, IN // This baseclass calling is needed, else compiler will complain about nullability /// - public bool IsReadOnly => ((ICollection)this).IsReadOnly; + public bool IsReadOnly => false; // 'new' keyword is required! we can explicitly implement ICollection.Add BUT since normally a concrete PropertyType type // is passed in, the explicit implementation doesn't get called, this ensures it does get called.