Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Resharper format line-wrapped ternary operators in the following way

I really want Resharper to format my line-wrapped ternaries in this way

return
    navigator.IsTerminating ?
    navigator.Context :
    navigator.Context.GetSimulatableRelative(new Navigator(navigator));

Can anyone help with this?

like image 251
Bryan Edds Avatar asked Apr 07 '12 19:04

Bryan Edds


1 Answers

I don't think there is an out of the box way of doing this. The only way i know to influence how R# formats code is through these settings:

Resharper --> Options... --> Langauges --> C# --> Formatting Style

Resharper Options Screenshot

This doesn't allow you to write your own custom formatting rules though.

If you feel like a challenge then you could write a plugin. There is some docs and an SDK:

  • Developer Docs
  • SDK
  • A video tutorial
like image 181
Robbie Avatar answered Nov 12 '22 17:11

Robbie