@@ -3319,22 +3319,28 @@ private TranslatedExpression TranslateInterpolatedString(Block block)
33193319 for ( int i = 1 ; i < block . Instructions . Count ; i ++ )
33203320 {
33213321 var call = ( Call ) block . Instructions [ i ] ;
3322+
3323+ Interpolation BuildInterpolation ( int alignment = 0 , string suffix = null )
3324+ {
3325+ return new Interpolation ( Translate ( call . Arguments [ 1 ] ) . ConvertTo ( call . GetParameter ( 1 ) . Type , this , allowImplicitConversion : true ) , alignment , suffix ) ;
3326+ }
3327+
33223328 switch ( call . Method . Name )
33233329 {
33243330 case "AppendLiteral" :
33253331 content . Add ( new InterpolatedStringText ( ( ( LdStr ) call . Arguments [ 1 ] ) . Value . Replace ( "{" , "{{" ) . Replace ( "}" , "}}" ) ) ) ;
33263332 break ;
33273333 case "AppendFormatted" when call . Arguments . Count == 2 :
3328- content . Add ( new Interpolation ( Translate ( call . Arguments [ 1 ] ) ) ) ;
3334+ content . Add ( BuildInterpolation ( ) ) ;
33293335 break ;
33303336 case "AppendFormatted" when call . Arguments . Count == 3 && call . Arguments [ 2 ] is LdStr ldstr :
3331- content . Add ( new Interpolation ( Translate ( call . Arguments [ 1 ] ) , suffix : ldstr . Value ) ) ;
3337+ content . Add ( BuildInterpolation ( suffix : ldstr . Value ) ) ;
33323338 break ;
33333339 case "AppendFormatted" when call . Arguments . Count == 3 && call . Arguments [ 2 ] is LdcI4 ldci4 :
3334- content . Add ( new Interpolation ( Translate ( call . Arguments [ 1 ] ) , alignment : ldci4 . Value ) ) ;
3340+ content . Add ( BuildInterpolation ( alignment : ldci4 . Value ) ) ;
33353341 break ;
33363342 case "AppendFormatted" when call . Arguments . Count == 4 && call . Arguments [ 2 ] is LdcI4 ldci4 && call . Arguments [ 3 ] is LdStr ldstr :
3337- content . Add ( new Interpolation ( Translate ( call . Arguments [ 1 ] ) , ldci4 . Value , ldstr . Value ) ) ;
3343+ content . Add ( BuildInterpolation ( ldci4 . Value , ldstr . Value ) ) ;
33383344 break ;
33393345 default :
33403346 throw new NotSupportedException ( ) ;
0 commit comments