Breaking of code embedded in raw strings with string interpolation
Input:
See output.
Output:
var v = $"""
abcde abcde abcde abcde abcde {string.Join(
", ",
new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
)}
""";
Expected behavior:
Not sure :). Maybe this?
var v = $"""
abcde abcde abcde abcde abcde {
string.Join(", ", new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 })
}
""";
or
var v = $"""
abcde abcde abcde abcde abcde {
string.Join(
", ",
new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
)
}
""";
I just don't think the current formatting is ideal.
Btw this is changed behavior from 0.26.0. I think until the current version it wouldn't even warp this code, not sure.
Right now there is no formatting applied to expressions that appear within a raw interpolated string.
From what I recall, the original interpolated strings did not allow line breaks in any expressions within them. So CSharpier was forcing those expressions to be flat. When raw interpolated strings were first supported in CSharpier, they were treated the same way which would have resulted in
var v = $"""
abcde abcde abcde abcde abcde {string.Join(", ", new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 })}
""";
And then when I was getting raw strings to indent correctly, the side effect was that I removed all formatting from the expressions in them.
Long story short, I believe it should be possible to get expressions within raw strings to format.