Examples of errors detected by the V3115 diagnostic

V3115. It is not recommended to throw exceptions from 'Equals(object obj)' method.


GitExtensions

V3115 Passing 'null' to 'Equals(object obj)' method should not result in 'NullReferenceException'. Git.hub Organization.cs 14


public override bool Equals(object obj)
{
  return GetHashCode() == obj.GetHashCode(); // <=
}

Identical errors can be found in some other places:

  • V3115 Passing 'null' to 'Equals(object obj)' method should not result in 'NullReferenceException'. Git.hub User.cs 16


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;