Replace a method call with another

I need to replace all characters obj.Method1()with obj.Method2(), where objare instances of the same class. Does ReSharper or VS2010 allow this?

+3
source share
3 answers

I would cheat - do a 3-point symbolic rename (right click-> rename method name)

  • Method1 → Temp
  • Method2 → Method1
  • Temp → Method2

None of this will change the functionality of the code, but it will update all your code to use the correct name, except that the methods themselves are now incorrectly named - just rename the methods manually and voila - A little hacked, but fast and efficient.

, ( VS , / ). XML, # , VB - , , ReSharper, #?

, ( , /)

+4

ReSharper Replace Pattern (ReSharper- > Tools- > , ) :

enter image description here

obj ( Method1).

, Method1():

enter image description here

, Method1 Method2.

+6

Make the body of method1 as follows

public void Method1(...) { return Method2(...); }

And call the "Inline method" refactoring in Method1.

0
source

All Articles