Skip to content

Commit fb9bdd1

Browse files
committed
Fix polymorphisms for items are applied to container for abstract container instantiation.
1 parent fb1db57 commit fb9bdd1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/MsgPack/Serialization/Polymorphic/PolymorphicSerializerProvider`1.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ public override object Get( SerializationContext context, object providerParamet
4040
{
4141
var schema = providerParameter as PolymorphismSchema;
4242

43-
if ( schema == null || schema.UseDefault )
43+
if ( schema == null || schema.UseDefault || schema.TargetType != typeof( T ) )
4444
{
45+
// No schema is applied or this provider is used for container but the schema is only applied for keys/items.
4546
if ( this._defaultSerializer == null )
4647
{
4748
throw SerializationExceptions.NewNotSupportedBecauseCannotInstanciateAbstractType( typeof( T ) );

0 commit comments

Comments
 (0)