[mcs] Handle interpolated strings with escaped quotes. Fixes #45286
authorMarek Safar <marek.safar@gmail.com>
Wed, 12 Oct 2016 15:31:47 +0000 (17:31 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 12 Oct 2016 15:31:47 +0000 (17:31 +0200)
mcs/mcs/cs-tokenizer.cs
mcs/tests/test-interpolation-05.cs
mcs/tests/ver-il-net_4_x.xml

index 1915a07240b379fdf4443385f6bd5a0af1e07783..e6a95fe8163a3590acb9f23602cc10d4cdec63dd 100644 (file)
@@ -2465,6 +2465,12 @@ namespace Mono.CSharp
                                case '\"':
                                        ++str_quote;
                                        break;
+                               case '\\':
+                                       // Skip escaped " character
+                                       c = reader.Read ();
+                                       if (c == -1)
+                                               res = false;
+                                       break;
                                case -1:
                                        res = false;
                                        break;
index 3dd99f5f2797f7c0db8b3b033fa08dedab20f9ca..4cf2e64196bd6b4a50cd1036eb0f2225dd3a5036 100644 (file)
@@ -13,6 +13,13 @@ public class ParserTest
                Console.WriteLine($"This should work but the compiler explodes if the string is too long!");            
        }
 
+       void Test3 ()
+       {
+               string field = "";
+               var l1 = $"\"{field.Replace("\"", "gg")}\"";
+               var l2 = $@"""{field.Replace("\"", "gg")}""";
+       }
+
        public static void Main()
        {
        }
index 0ac3d56b53db124bf9f98bfae87da7b2ecf8f4cc..56e35f7709f857723d5c158e14535337098d1e93 100644 (file)
       <method name="Void Test2()" attrs="129">
         <size>12</size>
       </method>
+      <method name="Void Test3()" attrs="129">
+        <size>62</size>
+      </method>
     </type>
   </test>
   <test name="test-interpolation-06.cs">