C#


ROSLYN.DESIGN.CA1066 : Implement IEquatable when overriding Object.Equals (C#)

See Roslyn-Detected C# Warning Classes for more information.

要旨

When a type T overrides Object.Equals(object), the implementation must cast the object argument to the correct type T before performing the comparison. If the type implements IEquatable, and therefore offers the method T.Equals(T), and if the argument is known at compile time to be of type T, then the compiler can call IEquatable.Equals(T) instead of Object.Equals(object), and no cast is necessary, improving performance.

この指摘はRoslynのCA1066に該当します。ルール詳細につい ては、下記リンクを参照してください。 CA1066

プロパティ

クラス名 Implement IEquatable when overriding Object.Equals (C#)
日本語クラス名 Implement IEquatable when overriding Object.Equals (C#)
クラス分類 信頼性 (reliability)
ニーモニック ROSLYN.DESIGN.CA1066
カテゴリー なし
対応言語 C# で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Implement IEquatable when overriding Object.Equals (C#)"

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。