Description
A BsonSerializationException is thrown when attempting to use the strongly typed update builder to set a subclass type. The following code reproduces the issue:
[BsonKnownTypes(typeof(B))]
|
public abstract class A
|
{
|
|
|
}
|
|
|
public class B : A
|
{
|
|
|
}
|
|
|
public class C
|
{
|
[BsonElement("a")]
|
public A A { get; set; }
|
}
|
|
|
class Program
|
{
|
static void Main(string[] args)
|
{
|
var b = new B();
|
|
|
var s = Update.SetWrapped("a", b);
|
var t = Update<C>.Set(c => c.A, b); // throws BsonSerializationException
|
}
|
}
|