Visual Studio 2022 quick action from constructor parameter to auto field creation not adding space

Viewed 471

In VS 2022, when I press Ctrl + . on a constructor parameter and select "Create and assign field/property", the resulting code is missing spaces around the assignment operator = like this:

_logger=logger

It's not a big deal obviously but annoying to fix manually for unified formatting (defeats the purpose of quick action). Is there a setting somewhere that can fix this?

2 Answers

You can reset your Visual Studio settings:

Tools => Import and Export Settings => Reset all settings

This will reset all your settings (you can create a backup in the process). After the reset, spaces will be back to normal.

If you want to avoid to reset all settings: this behavior is controlled by the following setting:

Shows options dialog for setting

It is set to Ignore spaces around binary operators by default; if you change this to Insert space before and after binary operators the space will be added.

Related