Avoid using PredicateOf<T>.Always since it does not work with full-aot. Fix bug ...
authorSebastien Pouliot <sebastien@xamarin.com>
Sun, 17 Jul 2011 20:35:15 +0000 (16:35 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 7 Nov 2012 18:38:15 +0000 (13:38 -0500)
mcs/class/System.Core/System.Linq/Enumerable.cs

index 0f9b717b4af71fb1ebd043426132fb0490269ea9..0dcdb6d8191a9d474e40e30fa5f066376027f933 100644 (file)
@@ -45,9 +45,11 @@ namespace System.Linq
                        Throw
                }
 
+#if !FULL_AOT_RUNTIME
                static class PredicateOf<T> {
                        public static readonly Func<T, bool> Always = (t) => true;
                }
+#endif
 
                static class Function<T> {
                        public static readonly Func<T, T> Identity = (t) => t;
@@ -849,7 +851,11 @@ namespace System.Linq
                {
                        Check.Source (source);
 
+#if !FULL_AOT_RUNTIME
                        return source.First (PredicateOf<TSource>.Always, Fallback.Default);
+#else
+                       return source.First (delegate { return true; }, Fallback.Default);
+#endif
                }
 
                public static TSource FirstOrDefault<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate)
@@ -1208,7 +1214,11 @@ namespace System.Linq
                        if (list != null)
                                return list [list.Count - 1];
 
+#if !FULL_AOT_RUNTIME
                        return source.Last (PredicateOf<TSource>.Always, Fallback.Throw);
+#else
+                       return source.Last (delegate { return true; }, Fallback.Throw);
+#endif
                }
 
                public static TSource Last<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate)
@@ -1230,7 +1240,11 @@ namespace System.Linq
                        if (list != null)
                                return list.Count > 0 ? list [list.Count - 1] : default (TSource);
 
+#if !FULL_AOT_RUNTIME
                        return source.Last (PredicateOf<TSource>.Always, Fallback.Default);
+#else
+                       return source.Last (delegate { return true; }, Fallback.Default);
+#endif
                }
 
                public static TSource LastOrDefault<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate)
@@ -2343,7 +2357,11 @@ namespace System.Linq
                {
                        Check.Source (source);
 
+#if !FULL_AOT_RUNTIME
                        return source.Single (PredicateOf<TSource>.Always, Fallback.Throw);
+#else
+                       return source.Single (delegate { return true; }, Fallback.Throw);
+#endif
                }
 
                public static TSource Single<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate)
@@ -2361,7 +2379,11 @@ namespace System.Linq
                {
                        Check.Source (source);
 
+#if !FULL_AOT_RUNTIME
                        return source.Single (PredicateOf<TSource>.Always, Fallback.Default);
+#else
+                       return source.Single (delegate { return true; }, Fallback.Default);
+#endif
                }
 
                public static TSource SingleOrDefault<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate)