The requested page is not available for the requested platform. You are viewing the content for Default platform.

Declare Property with Initializer

Purpose

Declares a property for the current parameter and initializes it. This Code Provider is useful for Test-Driven Development. It allows you to easily create declarations for properties referenced in a code fragment.

Note

Property declared in the interface is automatically added to all its implementers.

Availability

Available when the caret is on a method parameter within the method signature.

Usage

  1. Place the caret on an undeclared parameter.

  2. Hit Ctrl + . or Ctrl + ~ to invoke the Code Actions Menu.

  3. Use the mouse to select Declare | Declare Property with Initializer from the menu and press Enter. The red target picker marker appears. It allows you to choose the place where the generated code can be inserted.

  4. Use the Up Arrow and Down Arrow keys to move the target picker.

  5. Press Enter to generate a code in the selected place.

After execution, the Code Provider adds the auto-implemented property to the current class and assigns the parameter value to it.

The following screencast shows the described steps in action.

DeclarePropertyWith

You can configure the Target Picker on the Editor | All Languages | Code Actions | Target Picker options page.

TargetPicker