diff --git a/Composite/Core/Serialization/CompositeJsonSerializer.cs b/Composite/Core/Serialization/CompositeJsonSerializer.cs index c1f88eebe..9fa8fea2f 100644 --- a/Composite/Core/Serialization/CompositeJsonSerializer.cs +++ b/Composite/Core/Serialization/CompositeJsonSerializer.cs @@ -132,7 +132,8 @@ public static T Deserialize(string str) var obj = JsonConvert.DeserializeObject(str, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto, - Binder = CompositeSerializationBinder.Instance + Binder = CompositeSerializationBinder.Instance, + MaxDepth = 128 }); return obj; @@ -168,7 +169,8 @@ public static T Deserialize(params string[] strs) var obj = JsonConvert.DeserializeObject(combinedObj.ToString(), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto, - Binder = CompositeSerializationBinder.Instance + Binder = CompositeSerializationBinder.Instance, + MaxDepth = 128 }); return obj; @@ -184,7 +186,8 @@ public static object Deserialize(string str) var obj = JsonConvert.DeserializeObject(str, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects, - Binder = CompositeSerializationBinder.Instance + Binder = CompositeSerializationBinder.Instance, + MaxDepth = 128 }); return obj; diff --git a/Composite/Core/Serialization/CompositeSerializationBinder.cs b/Composite/Core/Serialization/CompositeSerializationBinder.cs index 987401fc4..0c563974e 100644 --- a/Composite/Core/Serialization/CompositeSerializationBinder.cs +++ b/Composite/Core/Serialization/CompositeSerializationBinder.cs @@ -45,19 +45,30 @@ public override Type BindToType(string assemblyName, string typeName) var type = base.BindToType(assemblyName, typeName); - if (!TypeIsSupported(assemblyName, typeName, type)) - { - throw new NotSupportedException($"Not supported object type '{typeName}'"); - } + VerityTypeIsSupported(new AssemblyName(assemblyName), typeName, type); return type; } - private bool TypeIsSupported(string assemblyName, string typeName, Type type) + private void VerityTypeIsSupported(AssemblyName assemblyName, string typeFullName, Type type) { - assemblyName = new AssemblyName(assemblyName).Name; + if (!TypeIsSupported(assemblyName, typeFullName, type)) + { + throw new NotSupportedException($"Not supported object type '{typeFullName}'"); + } - if (assemblyName == typeof(object).Assembly.GetName().Name /* "mscorlib" */) + if (type.IsGenericType) + { + foreach (var typeArgument in type.GetGenericArguments()) + { + VerityTypeIsSupported(typeArgument.Assembly.GetName(), typeArgument.FullName, typeArgument); + } + } + } + + private bool TypeIsSupported(AssemblyName assemblyName, string typeName, Type type) + { + if (assemblyName.Name == typeof(object).Assembly.GetName().Name /* "mscorlib" */) { var dotOffset = typeName.LastIndexOf(".", StringComparison.Ordinal); if (dotOffset > 0)