user1325696
user1325696

Reputation: 625

Resharper Initialize field from constructor not available in 2017.1

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

Answers (3)

Augusto Barreto
Augusto Barreto

Reputation: 3695

On my case it was not available because I disabled Build Warnings in Project Settings:

enter image description here

Also, suppressing warning 0169 may cause this. More info: Resharper Support

Upvotes: 1

Stridemann
Stridemann

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"

enter image description here

Upvotes: 0

Allan F. Gagnon
Allan F. Gagnon

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) or ctorp (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

Related Questions