- 2 min to read
Declares a property for the current reference to an undeclared element. This Code Provider is useful for Test-Driven Development. It allows you to easily create declarations for properties referenced in a code fragment.
Property declared in the interface is automatically added to all its implementers.
Available when the caret is on an undeclared variable reference.
Place the caret on an undeclared variable reference.
Hit Ctrl + . or Ctrl + ~ to invoke the Code Actions Menu.
Use the mouse to select Declare Property (with default body), Declare Property (auto-implemented) or Declare Property (with field) from the Declare menu and press Enter. The red target picker marker appears. It allows you to choose the place where the generated code can be inserted.
Use the Up Arrow and Down Arrow keys to move the target picker.
Press Enter to generate a code in the selected place.
The generated code depends on what Code Provider you selected and how the property was used in the original code. If you call the Code Provider for a variable contained in the right part of an expression, the provider will generate a read-only property; otherwise, the provider will declare a read-write property.
If you have chosen the Declare Property (with default body), the Code Provider will generate a property which throws the NotImplemented exception.
If you have chosen the Declare Property (auto-implemented), the Code Provider will generate an auto-implemented property.
If you have chosen the Declare Property (with field), the Code Provider will generate a property with a backing store.
You can configure the Target Picker on the Editor | All Languages | Code Actions | Target Picker options page.