RefactoringEssentials
RefactoringEssentials copied to clipboard
Feature request: Refactor to initialize instance through ctor
class C {
public int I1 { get; set; } public int I2 { get; set; } }
should be refactored to class C { public C(int i1, int i2) { this.I1 = i1; this.I2 = i2; }
public int I1 { get; set; } public int I2 { get; set; } }
optionally making setters private :), althrough this would mean to fix all ctor call sites. So maybe not.
This refactoring could help to make types immutable.
This is my most used feature in Resharper.
public class Foo {
public string Bar { get; }
}
To
public class Foo {
public Foo(string bar) {
Bar = bar;
}
public string Bar { get; }
}