-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.10.4
-
Component/s: BSON, Serialization
-
None
-
Environment:All environments
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Hello. When the regex is value of property in root document there is no problem. The problem seems to be just for nested properties
Here is a unit test.
Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
public static IEnumerable<object[]> TestData()
{
yield return new object[]
{
new BsonDocument
{
new BsonElement("field", new BsonRegularExpression("pattern"))
}
};
yield return new object[]
{
new BsonDocument
{
new BsonElement("field", new BsonDocument
{
new BsonElement("$regex", new BsonRegularExpression("pattern"))
})
}
};
}
[Theory]
[MemberData(nameof(TestData))]
public void Test(BsonDocument document)
{
var json = document.ToJson();
BsonSerializer.Deserialize<BsonDocument>(json);
}