tags:

views:

51

answers:

2

I am using ReSharper 5's "Reformat Code" feature using default settings and it converting this:

        _deviceInstanceView.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate()
        {
                  _deviceInstanceView._DeviceInstanceContainer.UpdateLayout();
        });

Into this:

         _deviceInstanceView.Dispatcher.Invoke(DispatcherPriority.Normal,
                                              (ThreadStart)
                                              delegate() { _deviceInstanceView._DeviceInstanceContainer.UpdateLayout(); });

Is there a way I can disable this formatting?

A: 

Play around with the options under Languages/C#/Formatting Style/Line Breaks & Wraps. You can tell it not to try to re-wrap lines at all, or change the conditions under which it will wrap, and where it will put the breaks.

This is pure personal preference, but I would tell it to prefer to wrap either before or after dots (your choice) and after commas, and to give curly braces their own line. You'd end up with something like:

_deviceInstanceView.Dispatcher
   .Invoke(DispatcherPriority.Normal, (ThreadStart)delegate()
         {
            _deviceInstanceView._DeviceInstanceContainer
               .UpdateLayout();
         }
   );
KeithS
When I put in your preferences, it still puts the curly bracket under delegate
Robert
A: 

ReSharper > Options > Languages > C# > Formatting Style > Braces Layout > Anonymous method declaration > At next line (BSD style)

As for moving the 2nd parameter to the next line, this could be because you have "Wrap formal parameters" set to "Chop always" or "Chop if long", but is more likely just because of "Wrap long lines".

Both of these are under ReSharper > Options > Languages > C# > Line Breaks and Wrapping > Line Wrapping

Jay
The curly bracket is still directly under the delegate when I make all those changes.
Robert