是否可以在Rider IDE中自动将getter / setter转换为构造函数args?我可以使用属性生成一个构造函数,但是看不到能够重构现有代码以使用该构造函数的功能。
当前代码
class MyClass {
public string FirstName {get;set;}
public string LastName {get;set;}
}
class AnotherClass {
public void AnotherFunction(){
var x = new MyClass{
FirstName = "Bill",
LastName = "Gates"
};
}
}
所需的重构
class MyClass {
public string FirstName {get;}
public string LastName {get;}
// I'm able to generate this
public MyClass(string firstName, string lastName){
FirstName = firstName;
LastName = lastName;
}
}
class AnotherClass {
public void AnotherFunction(){
// I don't see a way to refactor usages of MyClass to this.
var x = new MyClass("Bill", "Gates");
}
}