Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-274811: Extract method should allow to substitute same code in all places within a file

$
0
0
Reporter Eugene Petrenko (eugene.petrenko) Eugene Petrenko (eugene.petrenko)
Created Aug 10, 2011 4:14:50 PM
Updated Apr 23, 2018 8:35:18 PM
Subsystem Refactorings
Assignee Alisa Afonina (alisa.afonina)
Priority Major
State Open
Type Feature
Fix version Backlog
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
I have a use test where in each test on does the same things using different constants, i.e.
 public void Test_01(){ 
var f = CreateFactory("01");
DoSumeVooDoo("5");
Summarize("6");
}

public void Test_02(){
var f = CreateFactory("21");
DoSumeVooDoo("52");
Summarize("62");
}

As I wish to create DoTest method, I extract constants do:
 public void Test_02(){ 
var a = "21";
var b = "52";
var c = "62";

//extract the rest to a new method
var f = CreateFactory(a);
DoSumeVooDoo(b);
Summarize(c);
}

After I extract the rest as new method I'd like R# to search and replace same text in the file,
so, I with I get:
 public void DoTest(string a, string b, string c) {extracted }
public void Test_01(){
DoTest("01", "5", "6");
}

public void Test_02(){
DoTest("21", "52", "62");
}

This is also supported in Intellij IDEA

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>