• Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.10.4
    • Component/s: BSON, Serialization
    • Labels:
      None
    • Environment:
      All environments

      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);
              }
      

            Assignee:
            mikalai.mazurenka@mongodb.com Mikalai Mazurenka (Inactive)
            Reporter:
            muhaha45@gmail.com Tomáš Chroboček
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: