Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip overrides of a method when looking for all references

I would like to determine the impact that a code change within on override of Equals() in my class would have on the code.

  public override bool Equals(object obj)
  {
     // My code to be changed
     return true;
  }

When I do Shift-F12 to find all references, Visual Studio returns 126,703 places where I am calling object.Equals().

Is there a way to skip overrides of Equals() method when looking for references?

like image 790
GregC Avatar asked May 01 '12 14:05

GregC


1 Answers

Because the Equals method is defined at an object level, an object of your class could easily be passed to a method that calls Equals knowing nothing more than that it is an object.

For example, if you ever add your object to a HashSet, or if you call .Distinct() on a collection that includes your object, then you will be indirectly invoking Equals.

The only way to find all the places that overriding Equals will affect is to find all the places that your class is being used and see what is done with it.

like image 114
StriplingWarrior Avatar answered Oct 05 '22 11:10

StriplingWarrior