[Feature Request]: Code->Generate->"Generate fields from constructor parameters"
Hi,
I would like to have a way to generate class fields from constructor parameters.
E.g. for the following steps:
1) I write a constructor "definition" I want at caller side:
int one,two,three;
var myObj = new MyClass(one, two, three);
2) I let Resharper generate the constructor for me bu using Alt-Enter and "Create constructor".
3) Now I'm inside the new constructor with X parameters. Here is where the feature request starts. I want a way to generate fields for these variables, like:
MyClass(int one, int two, int three)
{
//Alt-Insert -> "Generate fields from constructor arguments" [maybe an option to generate fields as readonly as well?]
}
4) Now my class would look something like this:
private int _one;
private int _two;
private int _three;
MyClass(int one, int two, int three)
{
_one = one;
_two = two;
_three = three;
}
Do you think this would be something to consider in a future version?
Thanks,
Please sign in to leave a comment.
Hello GreenMoose,
on the parameter name
Press ALT+Enter
=> Introduce and Initialize 'parameter name'
Regards
Albert
Oh great, thanks :-)