Skip to content

Commit

Permalink
Merge pull request #802 from Orckestra/dev
Browse files Browse the repository at this point in the history
CompositeSerializationBinder - fixing a backward compatibility issue
  • Loading branch information
napernik authored Mar 28, 2022
2 parents 8bf8447 + 8013a5f commit a2c1c38
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Composite/Core/Serialization/CompositeSerializationBinder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using System.Runtime.Serialization;
using Composite.C1Console.Elements;
using Composite.C1Console.Security;
using Composite.Core.Types;
using Composite.Data;
Expand Down Expand Up @@ -42,15 +43,17 @@ public override Type BindToType(string assemblyName, string typeName)
if (result != null) return result;
}

if (!TypeIsSupported(assemblyName, typeName))
var type = base.BindToType(assemblyName, typeName);

if (!TypeIsSupported(assemblyName, typeName, type))
{
throw new NotSupportedException("Not supported object type");
throw new NotSupportedException($"Not supported object type '{typeName}'");
}

return base.BindToType(assemblyName, typeName);
return type;
}

private bool TypeIsSupported(string assemblyName, string typeName)
private bool TypeIsSupported(string assemblyName, string typeName, Type type)
{
assemblyName = new AssemblyName(assemblyName).Name;

Expand All @@ -65,11 +68,13 @@ private bool TypeIsSupported(string assemblyName, string typeName)
}
}

var type = base.BindToType(assemblyName, typeName);
return type != null
&& (type.IsEnum
|| typeof(EntityToken).IsAssignableFrom(type)
|| typeof(IDataId).IsAssignableFrom(type));
|| typeof(SearchToken).IsAssignableFrom(type)
|| typeof(IDataId).IsAssignableFrom(type)
|| type == typeof(DataSourceId)
|| type == typeof(DataScopeIdentifier));
}
}
}

0 comments on commit a2c1c38

Please sign in to comment.