-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.10.0
-
Component/s: Serialization
-
None
When BsonSerializationArgs is not provided the default value will sometimes have a null value for the NominalType.
This can result in an undesired `_t` discriminator value.
Reproduction:
namespace ConsoleApplication { public class C { public int X { get; set; } } public class Program { public static void Main() { var c = new C { X = 1 }; using (var stringWriter = new StringWriter()) using (var writer = new JsonWriter(stringWriter)) { BsonSerializer.Serialize(writer, c); var json = stringWriter.ToString(); } } } }
Results in:
"{ \"_t\" : \"C\", \"X\" : 1 }"
But the `_t` is not supposed to be there.
- is related to
-
CSHARP-2860 custom serializer not being called
- Closed
-
CSHARP-3889 System.InvalidOperationException: 'An Array value cannot be written to the root level of a BSON document.' when using MongoDB.Bson version 2.11.0 or higher
- Closed