Browse Source

Fix #2544: do not transform to interpolated string, if the format string is not syntactically correct.

pull/2549/head
Siegfried Pammer 4 years ago
parent
commit
65f2c54166
  1. 2
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS6_StringInterpolation.cs
  2. 7
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs

2
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS6_StringInterpolation.cs

@ -19,6 +19,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -19,6 +19,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine($"\ta{args ?? args}");
Console.WriteLine($"\ta{args[0][0] == 'a'}");
Console.WriteLine($"\ta{$"a{args.Length}" == args[0]}");
Console.WriteLine($"\ta{args.Length}}}");
}
public static void ArrayExpansionSpecialCases(object[] args)
@ -54,6 +55,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -54,6 +55,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(string.Format("{0:}", args.Length));
Console.WriteLine(string.Format("{0{a}0}", args.Length));
Console.WriteLine(string.Format("test: {0}", string.Join(",", args)));
Console.WriteLine(string.Format("test: {0}}", args.Length));
#pragma warning restore
}

7
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -670,9 +670,14 @@ namespace ICSharpCode.Decompiler.CSharp @@ -670,9 +670,14 @@ namespace ICSharpCode.Decompiler.CSharp
sb.Clear();
kind = TokenKind.String;
}
else if (Peek() == '}')
{
sb.Append("}}");
Next();
}
else
{
sb.Append((char)next);
yield return (TokenKind.Error, null);
}
break;
case ':':

Loading…
Cancel
Save