Skip to content

Obsolete Assert.Equals, and add an obsolete ReferenceEquals #5758

Closed
@Youssef1313

Description

@Youssef1313

Original issue was to remove this overload in v4:

/// <summary>
/// Static equals overloads are used for comparing instances of two types for reference
/// equality. This method should <b>not</b> be used for comparison of two instances for
/// equality. This object will <b>always</b> throw with Assert.Fail. Please use
/// Assert.AreEqual and associated overloads in your unit tests.
/// </summary>
/// <param name="objA"> Object A. </param>
/// <param name="objB"> Object B. </param>
/// <returns> False, always. </returns>
[SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "We want to compare 'object A' with 'object B', so it makes sense to have 'obj' in the parameter name")]
#pragma warning disable IDE0060 // Remove unused parameter
public static new bool Equals(object? objA, object? objB)
#pragma warning restore IDE0060 // Remove unused parameter
{
Fail(FrameworkMessages.DoNotUseAssertEquals);
return false;
}
#endregion

But we shouldn't. See comment below.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions