[CSHARP-4180] Correct handling NewExpression.Members when null Created: 22/May/22  Updated: 15/Jun/22  Resolved: 15/Jun/22

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Dmitry Lukyanov (Inactive) Assignee: Robert Stam
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-3922 LINQ3: support calls to constructors ... Closed
Epic Link: CSHARP-3615

 Description   

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


Generated at Wed Feb 07 21:47:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.