【发布时间】:2017-10-17 20:46:29
【问题描述】:
在我“提取类”以将一些方法提取到他们自己的类中之后,我就剩下原始方法包装对新类方法的调用。 Resharper 是否可以让我做进一步的重构,将所有用法重新指向新类的新方法,然后可能删除旧方法?
例如,在一个 Extract Class 重构之后,我可能有:
public class FooSource {
private BarSource _barSource = new BarSource();
public Foo GetFoo(...) {...}
public Foo GetFooByName(...) {...}
public Bar GetBar(...) => _barSource.GetBar(...); // now a wrapper due to refactoring
public Bar GetBarByName(...) => _barSource.GetBarByName(...); // now a wrapper due to refactoring
}
public class BarSource { // my new class just generated by Resharper
private FooSource _fooSource = FooSource(); // sometimes this reference is needed; sometimes not; not relevant to this question
public Bar GetBar(...) {...}
public Bar GetBarByName(...) {...}
}
从这里开始,我想重新指出 FooSource.GetBar 和 FooSource.GetBarByName 的所有用法,以改用我的新 BarSource 类的新实例。有什么可以帮助我自动完成大部分(甚至只是部分)这项工作吗?
【问题讨论】: