dotnet/wpf

CA1036: Override methods on comparable types

Open

#10.271 aberto em 13 de jan. de 2025

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)C# (1.126 forks)batch import
Good First Issuearea-Styling

Métricas do repositório

Stars
 (6.683 stars)
Métricas de merge de PR
 (Mesclagem média 2d 7h) (41 fundiu PRs em 30d)

Description

Link to the issue description: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1036

Rule Description

Types that define a custom sort order implement the IComparable interface. The CompareTo method returns an integer value that indicates the correct sort order for two instances of the type. This rule identifies types that set a sort order. Setting a sort order implies that the ordinary meaning of equality, inequality, less-than, and greater-than don't apply. When you provide an implementation of IComparable, you must usually also override Equals so that it returns values that are consistent with CompareTo. If you override Equals and are coding in a language that supports operator overloads, you should also provide operators that are consistent with Equals.

Guia do colaborador