Skip to content

ReferenceEquals on value types (CA2013)

Key dotnet.codequality.reference-equals-value-type · Severity error · Category codequality

Microsoft analyzer CA2013. Flags object.ReferenceEquals on value types. Each side is boxed into a new object, so the result is always false.

if (ReferenceEquals(orderId, otherId))
Merge();
if (orderId == otherId)
Merge();