File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,10 +223,14 @@ public virtual CodeExpression GetRhs()
223223 if ( type . IsGenericType ( typeof ( IReadOnlyList < > ) ) )
224224 {
225225 var elementType = type . GetGenericArguments ( ) [ 0 ] ;
226- var values = ( ( IEnumerable ) val ) . Cast < object > ( ) . ToList ( ) ;
227- return new CodeArrayCreateExpression (
228- elementType ?? throw new Exception ( $ "Type { type } was an IReadOnlyList<> but { nameof ( Type . GetGenericArguments ) } returned null") ,
229- values . Select ( v => v . ToCodePrimitiveExpression ( ) ) . ToArray ( ) ) ;
226+
227+ if ( elementType . IsPrimitive )
228+ {
229+ var values = ( ( IEnumerable ) val ) . Cast < object > ( ) . ToList ( ) ;
230+ return new CodeArrayCreateExpression (
231+ elementType ?? throw new Exception ( $ "Type { type } was an IReadOnlyList<> but { nameof ( Type . GetGenericArguments ) } returned null") ,
232+ values . Select ( v => v . ToCodePrimitiveExpression ( ) ) . ToArray ( ) ) ;
233+ }
230234 }
231235
232236 if ( val is IList valList )
You can’t perform that action at this time.
0 commit comments