14

ReSharper's formatting keeps placing string interpolations on different lines, such as:

$" whatever = {somethingelse}"

becomes:

$" whatever={
         somethingelse
      }"

Any idea which option this is?

Chris
  • 1,533
  • 2
  • 17
  • 33
Alan Ciantar
  • 278
  • 1
  • 3
  • 14
  • 6
    This has got to be a bug, no way should it format a string like it's code even if it kinda is now. – juharr Sep 17 '15 at 12:01
  • @juharr Yeah, looks like that to me too. Maybe related to [this](https://youtrack.jetbrains.com/issue/RSRP-434676) or [this](https://youtrack.jetbrains.com/issue/RSRP-447081). – Christian.K Sep 17 '15 at 12:56
  • 1
    What version of Resharper are you using? I think only 9 is suppose to work with 2015 and the new C# 6 stuff. – juharr Sep 17 '15 at 12:59
  • Latest. Just checked for updates this morning and im up to date. Quick googling didn't find the issue so I assumed it wasn't a bug. – Alan Ciantar Sep 17 '15 at 17:25
  • Didn't do that when I removed it a month ago (still a CPU hog). Must be a new bug – Panagiotis Kanavos Sep 18 '15 at 15:01
  • I am using ReSharper 9.2 and it formats the code correctly. – xtu Dec 22 '15 at 16:47
  • Using ReSharper 10 and this still happens. http://i.imgur.com/zyF1gyc.png – Alan Ciantar Jan 28 '16 at 12:13
  • Did you try exporting your ReSharper settings and resetting ReSharper's configuration? – Élie Mar 29 '16 at 10:27
  • Seams to work with Resharper latest version : 2016.1.1 on VS 2015. I do not use old versions of Resharper. Does old versions 9.2 or 10 have updates supporting C# 6 string interpolation ? – Renaud Bancel May 10 '16 at 15:00
  • Updated to latest and seems to be working. However, it's been a while and I've changed settings since then so not sure if I had inadvertently(?) fixed it anyway. – Alan Ciantar May 11 '16 at 14:18
  • Works for simple things like that. It seems to be failing on long sql queries. Like so: http://i.imgur.com/bbdymes.png becomes http://i.imgur.com/MHjbesb.png – Alan Ciantar May 13 '16 at 08:03
  • I believe your issue is answered here: http://stackoverflow.com/a/11746111/5038208 – chandler Jun 14 '16 at 21:53

1 Answers1

1

"Wrap object and collection initializer" is the setting you're after. Set it to chop if long and then if it's still wrapping incorrectly you can modify the "Right Margin (columns)" number to a much larger value and it will stop the behavior. Though by expanding the columns resharper will stop wrapping anything with fewer characters on the line than the value you set so it may make other reformatting perform in an undesirable way.

Resharper object initializer options

Resharper Column Options

P. Roe
  • 2,077
  • 1
  • 16
  • 23