Complete initialization

Initialization block scaffolding

MappingGenerator offers a set of code actions that allow for automatic completion of initialization blocks. Those refactorings are available in empty initialization blocks and allow to complete them in the following ways:

  • By assigning variables available in local scope matched using naming and type rules
  • By mapping lambda parameter (only inside the lambda)
  • By assigning dummy values appropriately based on the member type

Complete initialization with local scope

With the Initialize with local variables code action, you can complete the initialization block by automatically assigning variables available in the current scope to initialized object fields and properties based on matching conventions.

⭐ MappingGenerator in premium version allows for tweaking initialization block with UI Configurator.

Complete initialization with lambda parameter

Using Initialize with lambda parameter you map the lambda parameter to the initialized object:

⭐ MappingGenerator in premium version allows for tweaking lambda parameter mapping to initialized object with UI Configurator.

Complete initialization with dummy values

Initialize with sample values option allows for quick initialization block scaffolding by assigning sample values to the initialized object fields and properties: