C# ReSharper 换行和换行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11744690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 19:03:30  来源:igfitidea点击:

ReSharper Line Breaks and Wrapping

c#resharpercode-formatting

提问by ryancerium

So, this:

所以这:

cmd = new OdbcCommand( string.Format( @"
SELECT *
  FROM Bobby_Tables
 WHERE Name = {0}", "Little Bobby Drop Tables" ), odbcConnection );

gets formatted to:

被格式化为:

cmd = 
      new OdbcCommand( 
            string.Format( 
                  @"
SELECT *
  FROM Bobby_Tables
 WHERE Name = {0}", 
                  "Little Bobby Drop Tables" ), odbcConnection );

I've looked at each of the options for line breaks and wrapping but I haven't been able to find the one to keep things on the same line as long as possible. I'm assuming that I missed the correct option. My Right margin (columns)option is set to 100, which is plenty big.

我已经查看了换行和换行的每个选项,但我一直无法找到一个尽可能长时间保持在同一行上的选项。我假设我错过了正确的选项。我的Right margin (columns)选项设置为 100,这已经足够大了。

Question:Is there a way to make it look like the original, and still get smart formatting on other things that actually do need to be wrapped?

问题:有没有办法让它看起来像原始的,并且仍然可以对其他实际上需要包装的东西进行智能格式化?

I can manually put the

我可以手动把

cmd = new OdbcCommand( string.Format (
      @"

back on the first line and it'll leave the verbatim string on the next line happily. That's an alright compromise I guess.

回到第一行,它会高兴地将逐字字符串留在下一行。我想这是一个不错的妥协。

采纳答案by Dmitry Osinovskiy

I guess that your problem is that the first line got broken in three. This is because of bug http://youtrack.jetbrains.com/issue/RSRP-288271that was fixed in ReSharper 7.0. You should consider upgrading or turning off option ReSharper | Options -> Code Editing | C# | Formatting style | Line breaks and wrapping -> LineWrapping | Wrap long lines.

我猜你的问题是第一行被分成三行。这是因为在 ReSharper 7.0 中修复了错误http://youtrack.jetbrains.com/issue/RSRP-288271。您应该考虑升级或关闭选项ReSharper | Options -> Code Editing | C# | Formatting style | Line breaks and wrapping -> LineWrapping | Wrap long lines