如何让 Resharper 正确换行很长的线?

发布于 2024-10-27 23:38:44 字数 290 浏览 4 评论 0原文

Resharper 的代码格式通常都很好,但在处理很长的行时似乎完全被破坏了。例如,看看这段代码:

在此处输入图像描述

我确实想要某种换行,但它应该看起来如有必要,请提前并减少缩进,以避免出现大量换行符。像这样的东西会很棒:

在此处输入图像描述

有什么方法可以让 Resharper 执行此操作吗?

Resharper's code formatting is generally fine, but it seems completely broken when dealing with very long lines. For example look at this piece of code:

enter image description here

I do want some kind of line wrapping, but it should look ahead and indent less if necessary to avoid ridiculous amounts of line breaks. Something like this would be great:

enter image description here

Is there any way to make Resharper do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦罢 2024-11-03 23:38:44

Jetbrains 的 Alex Berezoutsky 建议关闭“ReSharper | 选项 | 语言 | C# | 格式化样式 | 其他”对话框中的“缩进数组、对象和集合初始值设定项”复选框。在我看来,对于较短的代码行来说,这不是理想的选择,但在很长的代码行上它看起来确实要好得多。

我想这是目前解决这个问题的最佳方法。

Alex Berezoutsky of Jetbrains has suggested to turn off "Indent array, object and collection initializer" checkbox in the "ReSharper | Options | Languages | C# | Formatting Style | Other" dialog. It's not ideal IMO for shorter lines, but it does look much better on very long code lines.

I guess it's the best workaround for this problem at the current time.

痴梦一场 2024-11-03 23:38:44

诚然,我还没有将您的代码插入我的 IDE 中进行尝试,因此我没有为您提供确切的设置值,但可以尝试调整 R# 选项中的换行选项。

  • 前往 Resharper | 在“语言”下展开“C#”,然后展开“格式样式”下的选项
  • ,单击“换行符和换行”
  • 检查该类别中的设置

I admittedly haven't plugged your code into my IDE to try it so I don't have exact setting values for you, but have a go at tweaking the line wrapping options in R# options.

  • Go to Resharper | Options
  • Under Languages expande C# and then Formatting Style, click on Line Breaks and Wrapping
  • Review the settings in that category
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文