1

my method

public void Method()
{
    OneAction;
}

need format in

Method() => OneAction;
1
  • That's not a Lambda, it's an expression body applied to a Method. You usually configure that style in the Options related to the language code style. Then you can run an analyzer (Code Cleanup) configured to handle expression / block body preferences. The code cleanup can also be configured to run on save (IIRC Options ->Text Editor -> Code cleanup), specifying the configured profile, if that's what you're talking about
    – Jimi
    Commented Mar 22 at 6:45

1 Answer 1

1
  • If you can accept manual formatting, you can place the cursor on your method and choose to apply this style to the document/project/solution from the IntelliCode suggestions.

    IC suggestions

  • If you insist on formatting when saving files, you can:

    1. Set the Use expression body for methods item in the C# code style to When possible

      Or add csharp_style_expression_bodied_methods = true to the .editorconfig file.

    2. Configure a code cleanup profile, adding the Apply expression/block body preferences item to fixer list.

      Code cleanup

    3. In the Text Editor > Code Cleanup options page, select the profile and enable Run Code Cleanup profile on Save

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.