Skip to content

Commit ccf388f

Browse files
committed
Fix AnonymousTypeWrapper cast failing on lists of structs
1 parent ac0b735 commit ccf388f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

RazorEngineCore/AnonymousTypeWrapper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
3939
result = new AnonymousTypeWrapper(result);
4040
}
4141

42-
bool isEnumerable = typeof(IEnumerable).IsAssignableFrom(type);
43-
4442
if (result is IDictionary dictionary)
4543
{
4644
List<object> keys = new List<object>();
@@ -58,9 +56,9 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
5856
}
5957
}
6058
}
61-
else if (isEnumerable && !(result is string))
59+
else if (result is IEnumerable enumer && !(result is string))
6260
{
63-
result = ((IEnumerable<object>)result)
61+
result = enumer.Cast<object>()
6462
.Select(e =>
6563
{
6664
if (e.IsAnonymous())

0 commit comments

Comments
 (0)