coderushforroslyn-117246-code-style-assistance-code-formatters.md
Code Formatters improve code readability and layout to match a certain style without code behavior change. For example, Sort Namespace References.
The topics in the Code Formatters section describe each code formatter in detail. The description includes the purpose of the code formatter, its availability and the “how to use” example.
Invoke the Code Actions Menu. Place the caret in the part of the code you want to change, for example, on a get statement inside the property declaration, and press Ctrl + . or Ctrl + ~.
Choose the action from the invoked menu. For example, Collapse Getter.
Press Enter to convert the accessor to a single-line form.
class TestClass
{
public int a;
public int A {
get { return a; }
set {
a = value;
}
}
}
The following table lists available code formatters and shows supported languages for them:
You can apply code formatters from code sections in .razor files.
Note
The code formatters for Blazor are unable to update references in closed .razor files. Make sure all files that may be impacted by a particular code formatter are open in Visual Studio before applying it.
See Also