Complete initialization

Initialization block scaffolding

MappingGenerator offers a set of code actions that allow for the automatic completion of initialization blocks. Those refactorings are available for object creation expressions and allow for completing the initialization block 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

Initialize with local variables (default settings)

With the Initialize with local variables code action, you can complete the initialization block by automatically assigning variables available in the current scope (local variables, method parameters, containing object fields and properties) to initialized object fields and properties based on matching conventions. Initialize with local variables (default settings) works in two modes

  • For non-premium version - executes completion using default settings with a basic set of converters.
  • For premium version - uses settings saved by the UI configurator (available under Initialize with local variables (custom settings)) and execute matching using premium converters

Initialize with local variables (custom settings)

This premium code action allows for tweaking mapping from local variables to the initialization block with UI Configurator. Settings saved by the configurator will be used later by Initialize with local variables (default settings):

Complete initialization with the lambda parameter

Using Initialize with lambda parameter you can map the lambda parameter to the initialized object. There are two versions of this code action:

  • Initialize with lambda parameter (default settings) - for non-premium users, it uses standard config with basic converters; for premium users, it takes configuration saved by the UI configurator and executes matching using premium converters
  • Initialize with lambda parameter (custom settings) - allows for tweaking mapping from lambda parameter to initialization block with UI Configurator

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

Initialize with sample values

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

If you require more customization for the object scaffolding please take a look at Advanced Object Scaffolder