Skip to content

Commit 64388a0

Browse files
authored
Fix IDE0004 for object comparison (#110206)
* Fix `IDE0004` for object comparison * revert `src/libraries/System.Private.CoreLib/src/System/RuntimeType.cs`
1 parent 2a0747c commit 64388a0

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ public override string ToString()
7676

7777
return vsb.ToString();
7878
}
79-
public override int GetHashCode() => base.GetHashCode();
80-
public override bool Equals(object? obj) => obj == (object)this;
8179
#endregion
8280

8381
#region Public Members

src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public bool EndsWith(string value, StringComparison comparisonType)
539539
{
540540
ArgumentNullException.ThrowIfNull(value);
541541

542-
if ((object)this == (object)value)
542+
if (ReferenceEquals(this, value))
543543
{
544544
CheckStringComparison(comparisonType);
545545
return true;
@@ -580,7 +580,7 @@ public bool EndsWith(string value, bool ignoreCase, CultureInfo? culture)
580580
{
581581
ArgumentNullException.ThrowIfNull(value);
582582

583-
if ((object)this == (object)value)
583+
if (ReferenceEquals(this, value))
584584
{
585585
return true;
586586
}
@@ -1108,7 +1108,7 @@ public bool StartsWith(string value, StringComparison comparisonType)
11081108
{
11091109
ArgumentNullException.ThrowIfNull(value);
11101110

1111-
if ((object)this == (object)value)
1111+
if (ReferenceEquals(this, value))
11121112
{
11131113
CheckStringComparison(comparisonType);
11141114
return true;
@@ -1158,7 +1158,7 @@ public bool StartsWith(string value, bool ignoreCase, CultureInfo? culture)
11581158
{
11591159
ArgumentNullException.ThrowIfNull(value);
11601160

1161-
if ((object)this == (object)value)
1161+
if (ReferenceEquals(this, value))
11621162
{
11631163
return true;
11641164
}

0 commit comments

Comments
 (0)