How to make Resharper format line-wrapped ternary

2019-03-19 02:00发布

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条回答
走好不送
2楼-- · 2019-03-19 02:19

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:

查看更多
登录 后发表回答