From fcfffa83081961154b4e2cdafca963a8e3c011ab Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Mon, 12 Mar 2018 17:48:07 +0000 Subject: [PATCH] hotfix array deserialisation --- SpeckleCore/Converter.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SpeckleCore/Converter.cs b/SpeckleCore/Converter.cs index b191fff..7147ad1 100644 --- a/SpeckleCore/Converter.cs +++ b/SpeckleCore/Converter.cs @@ -203,11 +203,18 @@ public static object Deserialise( SpeckleObject obj, object root = null ) { try { - var mySubList = Activator.CreateInstance( prop != null ? prop.PropertyType : field.FieldType ); - foreach ( var myObj in ( ( IEnumerable ) value ) ) - mySubList.GetType().GetMethod( "Add" ).Invoke( mySubList, new object[ ] { myObj } ); + if ( prop.PropertyType.IsArray || field.FieldType.IsArray ) + { + value = ( ( List ) value ).ToArray(); + } + else + { + var mySubList = Activator.CreateInstance( prop != null ? prop.PropertyType : field.FieldType ); + foreach ( var myObj in ( ( IEnumerable ) value ) ) + mySubList.GetType().GetMethod( "Add" ).Invoke( mySubList, new object[ ] { myObj } ); - value = mySubList; + value = mySubList; + } } catch { } }