Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReSharper: formatting of delegates

Tags:

resharper

I like my code formatted like this:

WithDataContext.Execute(
    delegate(DataContext dataContext)
    {
        // code goes here.
    });

ReSharper wants to auto-format it like this:

WithDataContext.Execute(
                           delegate(DataContext dataContext)
                               {
                                   // code goes here.
                               });

What options do I need to tweak to get what I want?

like image 287
Roger Lipscombe Avatar asked Feb 18 '10 15:02

Roger Lipscombe


2 Answers

ReSharper -> Options -> C# -> Formatting Style -> Braces Layout -> Anonymous method declaration

Set to "At next line (BSD style)"

ReSharper -> Options -> C# -> Formatting Style -> Other -> Align Multiline Constructs

Uncheck "Call Arguments" and you'll get what you're looking for.

like image 103
James Kolpack Avatar answered Oct 07 '22 00:10

James Kolpack


There isn't an option to format quite like that that I can find, but take a look at ReSharper|Options: Languages|C#|Formatting Style|Braces Layout. It has a number of options like anonymous type format.

like image 43
Nathan Taylor Avatar answered Oct 07 '22 01:10

Nathan Taylor