Skip to content

Commit 7a74430

Browse files
author
tznind
committed
Fix linear range codegen
1 parent 05667d4 commit 7a74430

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/ToCode/Property.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)