Skip to content

Commit 5318f75

Browse files
authored
Update equals (#85896)
1 parent d3eebef commit 5318f75

2 files changed

Lines changed: 11 additions & 20 deletions

File tree

src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ public PropertyTabAttribute(System.Type tabClass, System.ComponentModel.Property
11641164
public System.Type[] TabClasses { get { throw null; } }
11651165
protected string[]? TabClassNames { get { throw null; } }
11661166
public System.ComponentModel.PropertyTabScope[] TabScopes { get { throw null; } }
1167-
public bool Equals(System.ComponentModel.PropertyTabAttribute other) { throw null; }
1167+
public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.ComponentModel.PropertyTabAttribute? other) { throw null; }
11681168
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? other) { throw null; }
11691169
public override int GetHashCode() { throw null; }
11701170
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Types referenced by tabClassNames may be trimmed.")]

src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,34 +145,25 @@ private void InitializeTabClasses()
145145
public PropertyTabScope[] TabScopes { get; private set; }
146146

147147
public override bool Equals([NotNullWhen(true)] object? other)
148-
{
149-
if (other is PropertyTabAttribute propertyTabAttribute)
150-
{
151-
return Equals(propertyTabAttribute);
152-
}
153-
return false;
154-
}
148+
=> Equals(other as PropertyTabAttribute);
155149

156-
public bool Equals(PropertyTabAttribute other)
150+
public bool Equals([NotNullWhen(true)] PropertyTabAttribute? other)
157151
{
158-
if (other == (object)this)
159-
{
152+
if (other is null)
153+
return false;
154+
155+
if (ReferenceEquals(this, other))
160156
return true;
161-
}
162-
if (other.TabClasses.Length != TabClasses.Length ||
163-
other.TabScopes.Length != TabScopes.Length)
164-
{
157+
158+
if (other.TabClasses.Length != TabClasses.Length || other.TabScopes.Length != TabScopes.Length)
165159
return false;
166-
}
167160

168161
for (int i = 0; i < TabClasses.Length; i++)
169162
{
170-
if (TabClasses[i] != other.TabClasses[i] ||
171-
TabScopes[i] != other.TabScopes[i])
172-
{
163+
if (TabClasses[i] != other.TabClasses[i] || TabScopes[i] != other.TabScopes[i])
173164
return false;
174-
}
175165
}
166+
176167
return true;
177168
}
178169

0 commit comments

Comments
 (0)