We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We should report that equality comparisons within logical AND conditions should be done by comparing values first and collections last.
Example:
public class SomeData { public int Id { get; set; } public List<Data> Data { get; set; } public bool Equals(SomeData other) { return ((Data == other.Data) || (Data != null && Data.SequenceEqual(otherData))) && Id == other.Id; } }
should be reported and changed into:
public class SomeData { public int Id { get; set; } public List<Data> Data { get; set; } public bool Equals(SomeData other) { return Id == other.Id && ((Data == other.Data) || (Data != null && Data.SequenceEqual(otherData))); } }
The reason is that comparison on value types is normally faster than comparing lists.
Note: The term "Value types" here include enums, Guids and strings.
The text was updated successfully, but these errors were encountered:
Added new rule MiKo_5018 to call value comparisons before reference c…
9788b03
…omparisons (resolves #1090)
Updated new rule MiKo_5018 to simplify value comparisons
0a19d6a
(resolves #1090)
Successfully merging a pull request may close this issue.
We should report that equality comparisons within logical AND conditions should be done by comparing values first and collections last.
Example:
should be reported and changed into:
The reason is that comparison on value types is normally faster than comparing lists.
Note: The term "Value types" here include enums, Guids and strings.
The text was updated successfully, but these errors were encountered: