File tree 1 file changed +5
-2
lines changed
src/MongoDB.Bson/Serialization/Serializers
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -110,11 +110,14 @@ public DiscriminatedInterfaceSerializer(IDiscriminatorConvention discriminatorCo
110
110
111
111
_interfaceType = typeof ( TInterface ) ;
112
112
_discriminatorConvention = discriminatorConvention ?? interfaceSerializer . GetDiscriminatorConvention ( ) ;
113
- _objectSerializer = objectSerializer ?? new ObjectSerializer ( allowedTypes : type => typeof ( TInterface ) . IsAssignableFrom ( type ) ) ;
114
113
114
+ _objectSerializer = objectSerializer ?? BsonSerializer . LookupSerializer < object > ( ) ;
115
115
if ( _objectSerializer is ObjectSerializer standardObjectSerializer )
116
116
{
117
- _objectSerializer = standardObjectSerializer . WithDiscriminatorConvention ( _discriminatorConvention ) ;
117
+ Func < Type , bool > allowedTypes = ( Type type ) => typeof ( TInterface ) . IsAssignableFrom ( type ) ;
118
+ _objectSerializer = standardObjectSerializer
119
+ . WithDiscriminatorConvention ( _discriminatorConvention )
120
+ . WithAllowedTypes ( allowedTypes , allowedTypes ) ;
118
121
}
119
122
else
120
123
{
You can’t perform that action at this time.
0 commit comments