When I use "Convert to string interpolation" on a string.Format call with wrapped parameters that have leading spaces, the space is preserved in the interpolated string, when it should be collapsed.
To repro:
- Create a new C# Console app.
- Replace the initial Program.Main method with this:
static void Main(string[] args)
{
var first = "Bob";
var last = "Smith";
var fullName = string.Format("{0} {1}",
first,
last);
Console.WriteLine("Your name is " + fullName + ".");
Console.ReadLine();
}
- Use the "Convert to string interpolation" refactoring on the string.Format call. The interpolated items are correctly put on the same line, but their leading space is preserved when it shouldn't be:
Expected result:
var fullName = $"{first} {last}";
Actual result:
var fullName = $"{ first} { last}";
Hi Ryan,
Thank you for letting us know about this problem. I have reproduced this behavior locally and will pass this ticket to our developers for detailed research.