Reputation: 625
After I add a field I was able to press Ctrl + Enter and choose Initialize field from constructor
. It added an argument to existing ctor or created a new ctor with that argument if it was not declared.
I wonder if this is just new version Resharper 2017.1 or old version of VS 2013? I have it working on VS 2015 & Resharper 2016.3. But it doesn't appear when I press Ctrl + Enter in VS 2013 & Resharper 2017.1.
Upvotes: 4
Views: 2372
Reputation: 3695
On my case it was not available because I disabled Build Warnings in Project Settings:
Also, suppressing warning 0169 may cause this. More info: Resharper Support
Upvotes: 1
Reputation: 51
I found another refactoring bulb (Quick actions menu Ctrl+.) (at least in new version of resharper for VS 2022) that have a menu "Add parameter to XXX.ctor"
Upvotes: 0
Reputation: 320
ReSharper 2017.1 Help states the following:
Generating Type Constructors
ReSharper | Edit | Generate Code | Constructor
Alt+Insert | Constructor
ReSharper_GenerateConstructor
The constructor generation wizard creates a non-default constructor that takes parameters for selected fields , properties and auto-properties .
All generated constructors follow the same pattern where:
Each field , property, or auto-property included in the constructor is initialized with a parameter.
The name of the parameter is derived from the name of the corresponding field or property .
If there are non-default base type constructors, the required parameters are added to the generated constructor and passed to the base class constructor.
Tip You can quickly generate constructors by typing
ctor
(without parameters),ctorf
(with parameters that initialize all fields) orctorp
(with parameters that initialize all properties).Tip You can set up common code generation options on the Code Editing | Members Generation page of ReSharper options.
Upvotes: 2