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

99封情书 提交于 2019-12-04 10:40:48

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/10057786/how-to-make-resharper-format-line-wrapped-ternary-operators-in-the-following-way

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!