Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2003

$bitsAnySet and other bitwise expressions throw an Exception

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.17.0
    • Affects Version/s: 2.4.3, 2.4.4
    • Component/s: Linq, LINQ3
    • Labels:
    • Environment:
      Win10x64pro
      VS2017

      enum BE
      {
          b0 = 1<<0,
          b1 = 1<<1,
          b2 = 1<<2,
          b3 = 1<<3,
          b4 = 1<<4,
      }
      
      class BBB
      {
          public BE be;
      }
      
      public void foo(IMongoCollection coll)
      {
          coll.InsertMany(new []
          {
              new BBB{be=BE.b1},
              new BBB{be=BE.b2},
              new BBB{be=BE.b3},
              new BBB{be=BE.b4},
          });
      
          var mask = BE.b1 | BE.b3;
      
          var qb1 = coll.FindSync(b => (b.be & mask) != 0); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
          var qb2 = coll.FindSync(b => (b.be & mask) == 0); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
          var qb3 = coll.FindSync(b => (b.be & mask) != mask); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
          var qb4 = coll.FindSync(b => (b.be & mask) == mask); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
      
          var q1 = coll.AsQueryable().Where(b => (b.be & mask) != 0).ToList(); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
          var q2 = coll.AsQueryable().Where(b => (b.be & mask) == 0).ToList(); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
          var q3 = coll.AsQueryable().Where(b => (b.be & mask) != mask).ToList(); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
          var q4 = coll.AsQueryable().Where(b => (b.be & mask) == mask).ToList(); //System.InvalidOperationException: 'Convert(Convert((Convert({document}{be}) & 10))) is not supported.'
      }
      

      Looks like the behavior is different from MongoDB C# Driver documents.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            qaqz111 qaqz111
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: