1414 using Initialisations ;
1515 using NetStandardPolyfills ;
1616 using static System . Convert ;
17+ using static System . Environment ;
1718 using static System . Globalization . CultureInfo ;
1819#if NET35
1920 using static Microsoft . Scripting . Ast . ExpressionType ;
@@ -160,12 +161,14 @@ private static bool TryTranslateFromTypeCode(
160161 return true ;
161162
162163 case NetStandardTypeCode . String :
163- var stringValue = ( ( string ) constant . Value )
164- . Replace ( @"\" , @"\\" )
165- . Replace ( "\0 " , @"\0" )
166- . Replace ( @"""" , @"\""" ) ;
167-
164+ var stringValue = GetStringConstant ( constant , out var isVerbatim ) ;
168165 stringValue = "\" " + stringValue + "\" " ;
166+
167+ if ( isVerbatim )
168+ {
169+ stringValue = "@" + stringValue ;
170+ }
171+
169172 translation = FixedValueTranslation ( stringValue , typeof ( string ) , Text , context ) ;
170173 return true ;
171174 }
@@ -213,6 +216,13 @@ private static ITranslation GetDoubleTranslation(
213216 return FixedValueTranslation ( stringValue + "d" , constant . Type , Numeric , context ) ;
214217 }
215218
219+ private static ITranslation GetLongTranslation (
220+ ConstantExpression constant ,
221+ ITranslationContext context )
222+ {
223+ return FixedValueTranslation ( ( long ) constant . Value + "L" , constant . Type , Numeric , context ) ;
224+ }
225+
216226 private static ITranslation GetFloatTranslation (
217227 ConstantExpression constant ,
218228 ITranslationContext context )
@@ -226,11 +236,17 @@ private static ITranslation GetFloatTranslation(
226236 return FixedValueTranslation ( stringValue + "f" , constant . Type , Numeric , context ) ;
227237 }
228238
229- private static ITranslation GetLongTranslation (
239+ private static string GetStringConstant (
230240 ConstantExpression constant ,
231- ITranslationContext context )
241+ out bool isVerbatim )
232242 {
233- return FixedValueTranslation ( ( long ) constant . Value + "L" , constant . Type , Numeric , context ) ;
243+ var stringValue = ( string ) constant . Value ;
244+ isVerbatim = stringValue . Contains ( NewLine ) ;
245+
246+ return stringValue
247+ . Replace ( @"\" , @"\\" )
248+ . Replace ( "\0 " , @"\0" )
249+ . Replace ( @"""" , isVerbatim ? @"""""" : @"\""" ) ;
234250 }
235251
236252 private static bool TryGetTypeTranslation (
0 commit comments