From 5318f75f9040726f6d86fa35778df86b109f9658 Mon Sep 17 00:00:00 2001 From: hrrrrustic Date: Tue, 9 May 2023 20:00:08 +0300 Subject: [PATCH] Update equals (#85896) --- .../System.ComponentModel.TypeConverter.cs | 2 +- .../Design/PropertyTabAttribute.cs | 29 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs index a558073df7598..3ee62d98f3ccb 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs @@ -1164,7 +1164,7 @@ public PropertyTabAttribute(System.Type tabClass, System.ComponentModel.Property public System.Type[] TabClasses { get { throw null; } } protected string[]? TabClassNames { get { throw null; } } public System.ComponentModel.PropertyTabScope[] TabScopes { get { throw null; } } - public bool Equals(System.ComponentModel.PropertyTabAttribute other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.ComponentModel.PropertyTabAttribute? other) { throw null; } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? other) { throw null; } public override int GetHashCode() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Types referenced by tabClassNames may be trimmed.")] diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs index c4dc526139e4c..58fae021a6162 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs @@ -145,34 +145,25 @@ private void InitializeTabClasses() public PropertyTabScope[] TabScopes { get; private set; } public override bool Equals([NotNullWhen(true)] object? other) - { - if (other is PropertyTabAttribute propertyTabAttribute) - { - return Equals(propertyTabAttribute); - } - return false; - } + => Equals(other as PropertyTabAttribute); - public bool Equals(PropertyTabAttribute other) + public bool Equals([NotNullWhen(true)] PropertyTabAttribute? other) { - if (other == (object)this) - { + if (other is null) + return false; + + if (ReferenceEquals(this, other)) return true; - } - if (other.TabClasses.Length != TabClasses.Length || - other.TabScopes.Length != TabScopes.Length) - { + + if (other.TabClasses.Length != TabClasses.Length || other.TabScopes.Length != TabScopes.Length) return false; - } for (int i = 0; i < TabClasses.Length; i++) { - if (TabClasses[i] != other.TabClasses[i] || - TabScopes[i] != other.TabScopes[i]) - { + if (TabClasses[i] != other.TabClasses[i] || TabScopes[i] != other.TabScopes[i]) return false; - } } + return true; }