tags:

views:

57

answers:

2

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?

+1  A: 

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.

Nathan Taylor
By setting "Anonymous Method Declaration", I can get the delegate to line up properly. Good. Where are the extra spaces coming from at the start of the 'delegate' line?
Roger Lipscombe
+4  A: 

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.

James Kolpack
Sweet. Someone merge the two answers and you can have the rep.
Roger Lipscombe

related questions