Home > database >  Applying the Code Styling In Visual Studio 2022
Applying the Code Styling In Visual Studio 2022

Time:09-09

I need to setup a common code styling pattern which team needs to follow and will give warning or error to the developer while writing/compiling the code or pushing the code on the repository.

I have gone through couple of sites explaining about the EditorConfig file for setting up the styling in Visual Studio.

Also Gone through the link spacing for binary operators

For spaces after parameters, the control for this is "Insert space after comma". Again, this will be for all commas used throughout your code, not just for parameters:

comma spacing

Lastly, you can control the indentation settings you wish by looking under the Whitespace → Indentation and spacing section:

Indentation

For formatting on build you have some options. You can download a format on save extension, but that wouldn't format on "a build" technically. However I think because when a build is performed, a save of all files automatically occurs, and this should also format them.

One other way I've found is using the dotnet format post build event

  • Related