2 using System.Collections.Generic;
5 namespace OrderByBugExample
9 public string Name { get; set; }
10 public int Value1 { get; set; }
11 public int Value2 { get; set; }
16 public static int Main ()
18 List<Foo> test = new List<Foo> ()
20 new Foo { Name="b", Value1=37, Value2=2 },
21 new Foo { Name="b", Value1=37, Value2=1 }
24 // Sort using a linq expression. Mono 2.6.1 ignores item.Value2, which is incorrect behaviour.
25 var result = from item in test
26 orderby item.Name, item.Value1, item.Value2
29 var r = result.ToList ();
31 foreach (Foo item in r)
32 Console.WriteLine ("{0}, {1}, {2}", item.Name, item.Value1, item.Value2);
34 if (r[0].Value2 != 1 && r[1].Value2 != 2)
37 Console.WriteLine ("ok");