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

Correct handling NewExpression.Members when null

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: LINQ3
    • None

      Members fields in this loop can be null (and in line 59).
      Repro:

              static void Main(string[] args)
              {
                  var client = new MongoClient(new MongoClientSettings() { LinqProvider = Linq.LinqProvider.V3});
                  var db = client.GetDatabase("d");
                  var coll = db.GetCollection<Root>("c");
      
                  coll.InsertOne(new Root() { ForSelectMany = new[] { new WitDateTimeOffset { Date = DateTimeOffset.UtcNow} } });
      
                  var res = coll.AsQueryable()
                              .SelectMany(x => x.ForSelectMany)
                              .Select(y => new OutputWithMonth(y.Date.Month))
                              .ToList();
              }
      
      
              private class Root
              {
                  public IEnumerable<WitDateTimeOffset> ForSelectMany { get; internal set; }
              }
      
              public class WitDateTimeOffset
              {
                  public DateTimeOffset Date { get; set; }
              }
      
              private class OutputWithMonth
              {
                  public int Month;
      
                  public OutputWithMonth(int month) => Month = month;
              }
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: