SA1513 and Linq's GroupBy method

Jan 16, 2012 at 9:16 AM

There are a few closed issues concerning SA1513, but I can't find one that directly relates to this code. If you write:

            var tupleList = new List<Tuple<int, int>>()
                new Tuple<int, int>(1, 1),
                new Tuple<int, int>(1, 2)

            var grouped =
                from t in tupleList
                group t by new
                into g
                select new
                    Key = g.Key.Item1,
                    Values = g.Select(t => t.Item2).ToList()

SA1513: "Statements or elements wrapper in curly brackets must be followed by a blank line" suggests inserting a blank line between the "group" and "into" clauses. However, doing so subsequently raises SA1102: "The query clause must begin on the line after the previous clause, with no blank lines in between."

Is there a recommended way to format the code above, or does this reflect a bug in StyleCop?

Jan 16, 2012 at 9:45 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.