IEquatable<T> without Equals(object) (CA1067)
Anahtar dotnet.codequality.iequatable-without-equals · Önem warning · Kategori codequality
Microsoft analizörü CA1067. Equals(object)’i override etmeden IEquatable<T> uygulayan tipi işaretler. object sürümünü çağıran koleksiyonlar ve API’ler referansla karşılaştırır ve tipli sürümle çelişir.
Yanlış
Bölüm başlığı “Yanlış”public class Money : IEquatable<Money>{ public bool Equals(Money? other) => other is not null && Amount == other.Amount;}public class Money : IEquatable<Money>{ public bool Equals(Money? other) => other is not null && Amount == other.Amount; public override bool Equals(object? obj) => Equals(obj as Money); public override int GetHashCode() => Amount.GetHashCode();}