From f08b79744cd7923dd4cf1d9fa8dc77e4910f6bdc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 10:24:08 -0700 Subject: [PATCH 1/8] Use T4 to generate System.Interactive.Providers surface area. --- Ix.NET/Source/QueryableGenerator.t4 | 345 +++ .../System.Interactive.Providers.csproj | 19 + .../System/Linq/QueryableEx.Generated.cs | 2351 ++++------------- .../System/Linq/QueryableEx.Generated.tt | 14 + .../System/Linq/QueryableEx.cs | 7 + 5 files changed, 916 insertions(+), 1820 deletions(-) create mode 100644 Ix.NET/Source/QueryableGenerator.t4 create mode 100644 Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.tt diff --git a/Ix.NET/Source/QueryableGenerator.t4 b/Ix.NET/Source/QueryableGenerator.t4 new file mode 100644 index 0000000000..ded859ba2e --- /dev/null +++ b/Ix.NET/Source/QueryableGenerator.t4 @@ -0,0 +1,345 @@ +<#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Threading" #> +<#@ import namespace="System.Collections.Generic" #> +<# +var infoFieldNames = new Dictionary(); + +var toQuotedImpl = default(Func); +toQuotedImpl = (t, i, b) => +{ +var name = t.Name; + +if (t.IsGenericType) +{ + var genDef = t.GetGenericTypeDefinition(); + name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); + + var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; + + if (b) + { + if (name == "Func" || name == "Action") + { + name = "Expression<" + name + genArgs + ">"; + } + else if (name == "IEnumerable" && i == 0) + { + name = "IQueryable" + genArgs; + } + else if (name == "IOrderedEnumerable" && i == 0) + { + name = "IOrderedQueryable" + genArgs; + } + else + { + name += genArgs; + } + } + else + { + if (name == "Nullable") + { + name = genArgs.Substring(1, genArgs.Length - 2) + "?"; + } + else + { + name += genArgs; + } + } +} +else if (t.IsArray) +{ + var elem = toQuotedImpl(t.GetElementType(), i, b); + name = elem + "[]"; +} +else +{ + if (t == typeof(int)) + { + name = "int"; + } + else if (t == typeof(long)) + { + name = "long"; + } + else if (t == typeof(float)) + { + name = "float"; + } + else if (t == typeof(double)) + { + name = "double"; + } + else if (t == typeof(decimal)) + { + name = "decimal"; + } + else if (t == typeof(bool)) + { + name = "bool"; + } + else if (t == typeof(object)) + { + name = "object"; + } +} + +return name; +}; + +var toQuoted = new Func((t, i) => toQuotedImpl(t, i, true)); +var toCSharp = new Func(t => toQuotedImpl(t, 0, false)); +#> +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq.Expressions; +using System.Reflection; + +namespace System.Linq +{ + public static partial class <#=className#> + { +<# +// NOTE: Just including extension methods +foreach (var m in enumerableType.GetMethods() + .Where(m => m.IsStatic) + .Where(m => !exclude.Contains(m.Name)) + .Where(m => + { + if (m.ReturnType.IsGenericType) + { + if (m.ReturnType.GetGenericTypeDefinition() == typeof(IBuffer<>)) + { + return false; + } + } + + return true; + }) + .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + .Where(m => + { + var p0 = m.GetParameters()[0].ParameterType; + if (p0.IsGenericType) + { + var p0d = p0.GetGenericTypeDefinition(); + return p0d == typeof(IEnumerable<>) || p0d == typeof(IOrderedEnumerable<>); + } + + return false; + }) + .OrderBy(m => m.Name) + .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) + .ThenBy(m => m.GetParameters().Length) + .ThenBy(m => string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i) + " " + p.Name)))) +{ + var genArgs = m.GetGenericArguments(); + + var ret = toQuoted(m.ReturnType, 0); + var name = m.Name; + + if (genArgs.Length > 0) + { + name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; + } + + var isParams = false; + var parCount = m.GetParameters().Length; + + if (parCount != 0) + { + var lastParam = m.GetParameters().Last(); + + if (lastParam.IsDefined(typeof(ParamArrayAttribute), true)) + { + isParams = true; + } + } + + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + (nullableParameterNames.Contains(p.Name) ? "?" : "") + " " + p.Name)); + var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); + + if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + { + pars = "this " + pars; + } + + var infoName = m.Name; + var infoTypeArgs = ""; + var infoToGeneric = ""; + var infoMakeGeneric = ""; + var infoGenArgs = ""; + + if (genArgs.Length > 0) + { + infoName += "__" + string.Join("_", genArgs.Select(a => a.Name)); + infoTypeArgs = "(" + string.Join(", ", genArgs.Select(a => "Type " + a.Name)) + ")"; + infoToGeneric = ".GetGenericMethodDefinition()"; + infoMakeGeneric = ".MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => a.Name)) + ")"; + infoGenArgs = "<" + string.Join(", ", genArgs.Select(t => t.Name)) + ">"; + } + + infoName += "__" + parCount + "__"; + + int infoNameCount; + if (!infoFieldNames.TryGetValue(infoName, out infoNameCount)) + { + infoNameCount = 0; + } + + var infoNameId = infoNameCount++; + + infoFieldNames[infoName] = infoNameCount; + + infoName += infoNameId; + + var infoSignature = string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i)).Concat(new[] { toQuoted(m.ReturnType, 0) })); + + foreach (var genArg in genArgs) + { + //infoSignature = infoSignature.Replace(genArg.Name, "object"); + } + + var mtd = infoName; + + if (m.IsGenericMethod) + { + mtd += "(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; + } + + var provider = m.GetParameters()[0].Name + ".Provider"; + var factory = ""; + var rem = ""; + var cast = ""; + var quotedArgs = new List(); + var isAggregate = false; + + if (m.ReturnType.IsGenericType) + { + var td = m.ReturnType.GetGenericTypeDefinition(); + + if (td == typeof(Nullable<>) || td == typeof(IList<>)) + { + isAggregate = true; + } + else if (td == typeof(IEnumerable<>) || td == typeof(IOrderedEnumerable<>)) + { + factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + if (td == typeof(IOrderedEnumerable<>)) + { + cast = "(" + toQuoted(m.ReturnType, 0) + ")"; + } + } + } + else + { + isAggregate = true; + } + + if (isAggregate) + { + factory = "Execute<" + toQuotedImpl(m.ReturnType, -1, false) + ">"; + } + + var constraints = ""; + + if (m.IsGenericMethod) + { + constraints = string.Join(" ", m.GetGenericArguments().SelectMany(t => t.GetGenericParameterConstraints(), (t, c) => "where " + t.Name + " : " + c.Name)); + if (constraints.Length != 0) + { + constraints = " " + constraints; + } + } + + var n = 0; + foreach (var p in m.GetParameters()) + { + var pt = p.ParameterType; + + var add = false; + + if (pt.IsGenericType) + { + var ptd = pt.GetGenericTypeDefinition(); + + if (ptd == typeof(IEnumerable<>) || ptd == typeof(IOrderedEnumerable<>)) + { + if (n == 0) + { + quotedArgs.Add(p.Name + ".Expression"); + } + else + { + quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); + } + add = true; + } + else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) + { + quotedArgs.Add(p.Name); + add = true; + } + } + + if (!add) + { + quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); + } + + n++; + } + + var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; +#> + private static MethodInfo s_<#=infoName#>; + + private static MethodInfo <#=infoName#><#=infoTypeArgs#> => + (s_<#=infoName#> ?? + (s_<#=infoName#> = new Func<<#=infoSignature#>>(<#=m.Name#><#=infoGenArgs#>).GetMethodInfo()<#=infoToGeneric#>))<#=infoMakeGeneric#>; + + public static <#=ret#> <#=name#>(<#=pars#>)<#=constraints#> + { +<# +var any = false; +foreach (var p in m.GetParameters()) +{ + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) + { + any = true; +#> + if (<#=p.Name#> == null) + throw new ArgumentNullException(nameof(<#=p.Name#>)); +<# + } +} +#> +<# +if (any) +{ +#> + +<# +} + +#> + return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static <#=toCSharp(m.ReturnType)#> <#=name#>(<#=string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name))#>)<#=constraints#> + { + return <#=enumerableType.Name#>.<#=name#>(<#=string.Join(", ", m.GetParameters().Select(p => p.Name))#>); + } +#pragma warning restore 1591 + +<# +} +#> + } +} \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index e7015409d7..69afb32308 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -24,4 +24,23 @@ + + + QueryableEx.Generated.cs + TextTemplatingFileGenerator + + + + + + + + + + True + True + QueryableEx.Generated.tt + + + diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs index b5cbac93ea..a975bcedd2 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -11,1795 +11,731 @@ namespace System.Linq { public static partial class QueryableEx { - /// - /// Determines whether an enumerable sequence is empty. - /// - /// Source sequence element type. - /// Source sequence. - /// true if the sequence is empty; false otherwise. - public static bool IsEmpty(this IQueryable source) + private static MethodInfo s_Buffer__TSource__2__0; + + private static MethodInfo Buffer__TSource__2__0(Type TSource) => + (s_Buffer__TSource__2__0 ?? + (s_Buffer__TSource__2__0 = new Func, int, IQueryable>>(Buffer).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable> Buffer(this IQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Provider.Execute( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.IsEmpty(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); + return source.Provider.CreateQuery>(Expression.Call(Buffer__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static bool IsEmpty(IEnumerable source) + public static IEnumerable> Buffer(IEnumerable source, int count) { - return EnumerableEx.IsEmpty(source); + return EnumerableEx.Buffer(source, count); } #pragma warning restore 1591 - /// - /// Returns the minimum value in the enumerable sequence by using the specified comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to determine the minimum value. - /// Minimum value in the sequence. - public static TSource Min(this IQueryable source, IComparer comparer) + private static MethodInfo s_Buffer__TSource__3__0; + + private static MethodInfo Buffer__TSource__3__0(Type TSource) => + (s_Buffer__TSource__3__0 ?? + (s_Buffer__TSource__3__0 = new Func, int, int, IQueryable>>(Buffer).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable> Buffer(this IQueryable source, int count, int skip) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.Provider.Execute( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Min(default(IQueryable), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); + return source.Provider.CreateQuery>(Expression.Call(Buffer__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static TSource Min(IEnumerable source, IComparer comparer) + public static IEnumerable> Buffer(IEnumerable source, int count, int skip) { - return EnumerableEx.Min(source, comparer); + return EnumerableEx.Buffer(source, count, skip); } #pragma warning restore 1591 - /// - /// Returns the elements with the minimum key value by using the default comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// List with the elements that share the same minimum key value. - public static IList MinBy(this IQueryable source, Expression> keySelector) + private static MethodInfo s_Catch__TSource__1__0; + + private static MethodInfo Catch__TSource__1__0(Type TSource) => + (s_Catch__TSource__1__0 ?? + (s_Catch__TSource__1__0 = new Func>, IQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Catch(this IQueryable> sources) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MinBy(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); + return sources.Provider.CreateQuery(Expression.Call(Catch__TSource__1__0(typeof(TSource)), sources.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MinBy(IEnumerable source, Func keySelector) + public static IEnumerable Catch(IEnumerable> sources) { - return EnumerableEx.MinBy(source, keySelector); + return EnumerableEx.Catch(sources); } #pragma warning restore 1591 - /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// Comparer used to determine the minimum key value. - /// List with the elements that share the same minimum key value. - public static IList MinBy(this IQueryable source, Expression> keySelector, IComparer comparer) + private static MethodInfo s_Catch__TSource__2__0; + + private static MethodInfo Catch__TSource__2__0(Type TSource) => + (s_Catch__TSource__2__0 ?? + (s_Catch__TSource__2__0 = new Func, IEnumerable, IQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Catch(this IQueryable first, IEnumerable second) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MinBy(default(IQueryable), default(Expression>), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); + return first.Provider.CreateQuery(Expression.Call(Catch__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MinBy(IEnumerable source, Func keySelector, IComparer comparer) + public static IEnumerable Catch(IEnumerable first, IEnumerable second) { - return EnumerableEx.MinBy(source, keySelector, comparer); + return EnumerableEx.Catch(first, second); } #pragma warning restore 1591 - /// - /// Returns the maximum value in the enumerable sequence by using the specified comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to determine the maximum value. - /// Maximum value in the sequence. - public static TSource Max(this IQueryable source, IComparer comparer) + private static MethodInfo s_Catch__TSource_TException__2__0; + + private static MethodInfo Catch__TSource_TException__2__0(Type TSource, Type TException) => + (s_Catch__TSource_TException__2__0 ?? + (s_Catch__TSource_TException__2__0 = new Func, Expression>>, IQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TException); + + public static IQueryable Catch(this IQueryable source, Expression>> handler) where TException : Exception { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); - return source.Provider.Execute( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Max(default(IQueryable), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Catch__TSource_TException__2__0(typeof(TSource), typeof(TException)), source.Expression, handler)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static TSource Max(IEnumerable source, IComparer comparer) + public static IEnumerable Catch(IEnumerable source, Func> handler) where TException : Exception { - return EnumerableEx.Max(source, comparer); + return EnumerableEx.Catch(source, handler); } #pragma warning restore 1591 - /// - /// Returns the elements with the maximum key value by using the default comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// List with the elements that share the same maximum key value. - public static IList MaxBy(this IQueryable source, Expression> keySelector) + private static MethodInfo s_Concat__TSource__1__0; + + private static MethodInfo Concat__TSource__1__0(Type TSource) => + (s_Concat__TSource__1__0 ?? + (s_Concat__TSource__1__0 = new Func>, IQueryable>(Concat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Concat(this IQueryable> sources) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MaxBy(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); + return sources.Provider.CreateQuery(Expression.Call(Concat__TSource__1__0(typeof(TSource)), sources.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MaxBy(IEnumerable source, Func keySelector) + public static IEnumerable Concat(IEnumerable> sources) { - return EnumerableEx.MaxBy(source, keySelector); + return EnumerableEx.Concat(sources); } #pragma warning restore 1591 - /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// Comparer used to determine the maximum key value. - /// List with the elements that share the same maximum key value. - public static IList MaxBy(this IQueryable source, Expression> keySelector, IComparer comparer) + private static MethodInfo s_Distinct__TSource_TKey__2__0; + + private static MethodInfo Distinct__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__2__0 ?? + (s_Distinct__TSource_TKey__2__0 = new Func, Expression>, IQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + + public static IQueryable Distinct(this IQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MaxBy(default(IQueryable), default(Expression>), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MaxBy(IEnumerable source, Func keySelector, IComparer comparer) + public static IEnumerable Distinct(IEnumerable source, Func keySelector) { - return EnumerableEx.MaxBy(source, keySelector, comparer); + return EnumerableEx.Distinct(source, keySelector); } #pragma warning restore 1591 - /// - /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the source sequence. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Selector function with shared access to the source sequence for each enumerator. - /// Sequence resulting from applying the selector function to the shared view over the source sequence. - public static IQueryable Share(this IQueryable source, Expression, IEnumerable>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Share(default(IQueryable), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - selector - ) - ); - } + private static MethodInfo s_Distinct__TSource_TKey__3__0; + + private static MethodInfo Distinct__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__3__0 ?? + (s_Distinct__TSource_TKey__3__0 = new Func, Expression>, IEqualityComparer, IQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Share(IEnumerable source, Func, IEnumerable> selector) - { - return EnumerableEx.Share(source, selector); - } -#pragma warning restore 1591 - - /// - /// Publishes the source sequence within a selector function where each enumerator can obtain a view over a tail of the source sequence. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Selector function with published access to the source sequence for each enumerator. - /// Sequence resulting from applying the selector function to the published view over the source sequence. - public static IQueryable Publish(this IQueryable source, Expression, IEnumerable>> selector) + public static IQueryable Distinct(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Publish(default(IQueryable), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - selector - ) - ); + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Publish(IEnumerable source, Func, IEnumerable> selector) + public static IEnumerable Distinct(IEnumerable source, Func keySelector, IEqualityComparer comparer) { - return EnumerableEx.Publish(source, selector); + return EnumerableEx.Distinct(source, keySelector, comparer); } #pragma warning restore 1591 - /// - /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the sequence's elements without causing multiple enumerations over the source. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Selector function with memoized access to the source sequence for each enumerator. - /// Sequence resulting from applying the selector function to the memoized view over the source sequence. - public static IQueryable Memoize(this IQueryable source, Expression, IEnumerable>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + private static MethodInfo s_DistinctUntilChanged__TSource__1__0; + + private static MethodInfo DistinctUntilChanged__TSource__1__0(Type TSource) => + (s_DistinctUntilChanged__TSource__1__0 ?? + (s_DistinctUntilChanged__TSource__1__0 = new Func, IQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Memoize(default(IQueryable), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Memoize(IEnumerable source, Func, IEnumerable> selector) - { - return EnumerableEx.Memoize(source, selector); - } -#pragma warning restore 1591 - - /// - /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to all of the sequence's elements without causing multiple enumerations over the source. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Number of enumerators that can access the underlying buffer. Once every enumerator has obtained an element from the buffer, the element is removed from the buffer. - /// Selector function with memoized access to the source sequence for a specified number of enumerators. - /// Sequence resulting from applying the selector function to the memoized view over the source sequence. - public static IQueryable Memoize(this IQueryable source, int readerCount, Expression, IEnumerable>> selector) + public static IQueryable DistinctUntilChanged(this IQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Memoize(default(IQueryable), default(int), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - Expression.Constant(readerCount, typeof(int)), - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Memoize(IEnumerable source, int readerCount, Func, IEnumerable> selector) - { - return EnumerableEx.Memoize(source, readerCount, selector); - } -#pragma warning restore 1591 - /// - /// Creates an enumerable sequence based on an enumerator factory function. - /// - /// Result sequence element type. - /// Query provider. - /// Enumerator factory function. - /// Sequence that will invoke the enumerator factory upon a call to GetEnumerator. - public static IQueryable Create(this IQueryProvider provider, Expression>> getEnumerator) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (getEnumerator == null) - throw new ArgumentNullException(nameof(getEnumerator)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Create(default(IQueryProvider), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - getEnumerator - ) - ); + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource__1__0(typeof(TSource)), source.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Create(Func> getEnumerator) - { - return EnumerableEx.Create(getEnumerator); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence with a single element. - /// - /// Result sequence element type. - /// Query provider. - /// Single element of the resulting sequence. - /// Sequence with a single element. - public static IQueryable Return(this IQueryProvider provider, TResult value) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Return(default(IQueryProvider), default(TResult))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(value, typeof(TResult)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Return(TResult value) - { - return EnumerableEx.Return(value).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence that throws an exception upon enumeration. - /// - /// Result sequence element type. - /// Query provider. - /// Exception to throw upon enumerating the resulting sequence. - /// Sequence that throws the specified exception upon enumeration. - public static IQueryable Throw(this IQueryProvider provider, Exception exception) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (exception == null) - throw new ArgumentNullException(nameof(exception)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Throw(default(IQueryProvider), default(Exception))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(exception, typeof(Exception)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Throw(Exception exception) - { - return EnumerableEx.Throw(exception).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Creates an enumerable sequence based on an enumerable factory function. - /// - /// Result sequence element type. - /// Query provider. - /// Enumerable factory function. - /// Sequence that will invoke the enumerable factory upon a call to GetEnumerator. - public static IQueryable Defer(this IQueryProvider provider, Expression>> enumerableFactory) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (enumerableFactory == null) - throw new ArgumentNullException(nameof(enumerableFactory)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Defer(default(IQueryProvider), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - enumerableFactory - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Defer(Func> enumerableFactory) - { - return EnumerableEx.Defer(enumerableFactory).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence by mimicking a for loop. - /// - /// State type. - /// Result sequence element type. - /// Query provider. - /// Initial state of the generator loop. - /// Loop condition. - /// State update function to run after every iteration of the generator loop. - /// Result selector to compute resulting sequence elements. - /// Sequence obtained by running the generator loop, yielding computed elements. - public static IQueryable Generate(this IQueryProvider provider, TState initialState, Expression> condition, Expression> iterate, Expression> resultSelector) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (iterate == null) - throw new ArgumentNullException(nameof(iterate)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Generate(default(IQueryProvider), default(TState), default(Expression>), default(Expression>), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(initialState), - condition, - iterate, - resultSelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Generate(TState initialState, Func condition, Func iterate, Func resultSelector) + public static IEnumerable DistinctUntilChanged(IEnumerable source) { - return EnumerableEx.Generate(initialState, condition, iterate, resultSelector).AsQueryable(); + return EnumerableEx.DistinctUntilChanged(source); } #pragma warning restore 1591 - /// - /// Generates a sequence that's dependent on a resource object whose lifetime is determined by the sequence usage duration. - /// - /// Source element type. - /// Resource type. - /// Query provider. - /// Resource factory function. - /// Enumerable factory function, having access to the obtained resource. - /// Sequence whose use controls the lifetime of the associated obtained resource. - public static IQueryable Using(this IQueryProvider provider, Expression> resourceFactory, Expression>> enumerableFactory) where TResource : IDisposable - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (resourceFactory == null) - throw new ArgumentNullException(nameof(resourceFactory)); - if (enumerableFactory == null) - throw new ArgumentNullException(nameof(enumerableFactory)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Using(default(IQueryProvider), default(Expression>), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - resourceFactory, - enumerableFactory - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable - { - return EnumerableEx.Using(resourceFactory, enumerableFactory).AsQueryable(); - } -#pragma warning restore 1591 + private static MethodInfo s_DistinctUntilChanged__TSource__2__0; + + private static MethodInfo DistinctUntilChanged__TSource__2__0(Type TSource) => + (s_DistinctUntilChanged__TSource__2__0 ?? + (s_DistinctUntilChanged__TSource__2__0 = new Func, IEqualityComparer, IQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); - /// - /// Generates a sequence by repeating the given value infinitely. - /// - /// Result sequence element type. - /// Query provider. - /// Value to repreat in the resulting sequence. - /// Sequence repeating the given value infinitely. - public static IEnumerable Repeat(this IQueryProvider provider, TResult value) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryProvider), default(TResult))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(value, typeof(TResult)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Repeat(TResult value) - { - return EnumerableEx.Repeat(value).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that corresponds to the source sequence, concatenating it with the sequence resulting from calling an exception handler function in case of an error. - /// - /// Source sequence element type. - /// Exception type to catch. - /// Source sequence. - /// Handler to invoke when an exception of the specified type occurs. - /// Source sequence, concatenated with an exception handler result sequence in case of an error. - public static IQueryable Catch(this IQueryable source, Expression>> handler) - where TException : Exception + public static IQueryable DistinctUntilChanged(this IQueryable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (handler == null) - throw new ArgumentNullException(nameof(handler)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryable), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), -#endif - source.Expression, - handler - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Catch(IEnumerable source, Func> handler) - where TException : Exception - { - return EnumerableEx.Catch(source, handler); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. - /// - /// Source sequence element type. - /// Source sequences. - /// Sequence that continues to concatenate source sequences while errors occur. - public static IQueryable Catch(this IQueryable> sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryable>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - sources.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Catch(IEnumerable> sources) - { - return EnumerableEx.Catch(sources); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. - /// - /// Source sequence element type. - /// Query provider. - /// Source sequences. - /// Sequence that continues to concatenate source sequences while errors occur. - public static IQueryable Catch(this IQueryProvider provider, params IEnumerable[] sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryProvider), default(IEnumerable[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - GetSourceExpression(sources) - ) - ); + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Catch(params IEnumerable[] sources) + public static IEnumerable DistinctUntilChanged(IEnumerable source, IEqualityComparer comparer) { - return EnumerableEx.Catch(sources).AsQueryable(); + return EnumerableEx.DistinctUntilChanged(source, comparer); } #pragma warning restore 1591 - /// - /// Creates a sequence that returns the elements of the first sequence, switching to the second in case of an error. - /// - /// Source sequence element type. - /// First sequence. - /// Second sequence, concatenated to the result in case the first sequence completes exceptionally. - /// The first sequence, followed by the second sequence in case an error is produced. - public static IQueryable Catch(this IQueryable first, IEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - - return first.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - first.Expression, - GetSourceExpression(second) - ) - ); - } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__2__0; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__2__0 ?? + (s_DistinctUntilChanged__TSource_TKey__2__0 = new Func, Expression>, IQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Catch(IEnumerable first, IEnumerable second) - { - return EnumerableEx.Catch(first, second); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to run upon termination of the sequence, or when an enumerator is disposed. - /// Source sequence with guarantees on the invocation of the finally action. - public static IQueryable Finally(this IQueryable source, Expression finallyAction) + public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (finallyAction == null) - throw new ArgumentNullException(nameof(finallyAction)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Finally(default(IQueryable), default(Expression))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - finallyAction - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Finally(IEnumerable source, Action finallyAction) - { - return EnumerableEx.Finally(source, finallyAction); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that concatenates both given sequences, regardless of whether an error occurs. - /// - /// Source sequence element type. - /// First sequence. - /// Second sequence. - /// Sequence concatenating the elements of both sequences, ignoring errors. - public static IQueryable OnErrorResumeNext(this IQueryable first, IEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - - return first.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - first.Expression, - GetSourceExpression(second) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable OnErrorResumeNext(IEnumerable first, IEnumerable second) - { - return EnumerableEx.OnErrorResumeNext(first, second); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the sequences. - /// - /// Source sequence element type. - /// Query provider. - /// Source sequences. - /// Sequence concatenating the elements of the given sequences, ignoring errors. - public static IEnumerable OnErrorResumeNext(this IQueryProvider provider, params IEnumerable[] sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryProvider), default(IEnumerable[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - GetSourceExpression(sources) - ) - ); + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable OnErrorResumeNext(params IEnumerable[] sources) + public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector) { - return EnumerableEx.OnErrorResumeNext(sources).AsQueryable(); + return EnumerableEx.DistinctUntilChanged(source, keySelector); } #pragma warning restore 1591 - /// - /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the sequences. - /// - /// Source sequence element type. - /// Source sequences. - /// Sequence concatenating the elements of the given sequences, ignoring errors. - public static IQueryable OnErrorResumeNext(this IQueryable> sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryable>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - sources.Expression - ) - ); - } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__3__0; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__3__0 ?? + (s_DistinctUntilChanged__TSource_TKey__3__0 = new Func, Expression>, IEqualityComparer, IQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable OnErrorResumeNext(IEnumerable> sources) - { - return EnumerableEx.OnErrorResumeNext(sources); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that retries enumerating the source sequence as long as an error occurs. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence concatenating the results of the source sequence as long as an error occurs. - public static IQueryable Retry(this IQueryable source) + public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Retry(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Retry(IEnumerable source) + public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector, IEqualityComparer comparer) { - return EnumerableEx.Retry(source); + return EnumerableEx.DistinctUntilChanged(source, keySelector, comparer); } #pragma warning restore 1591 - /// - /// Creates a sequence that retries enumerating the source sequence as long as an error occurs, with the specified maximum number of retries. - /// - /// Source sequence element type. - /// Source sequence. - /// Maximum number of retries. - /// Sequence concatenating the results of the source sequence as long as an error occurs. - public static IQueryable Retry(this IQueryable source, int retryCount) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Retry(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(retryCount, typeof(int)) - ) - ); - } + private static MethodInfo s_Do__TSource__2__0; + + private static MethodInfo Do__TSource__2__0(Type TSource) => + (s_Do__TSource__2__0 ?? + (s_Do__TSource__2__0 = new Func, Expression>, IQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Retry(IEnumerable source, int retryCount) + public static IQueryable Do(this IQueryable source, Expression> onNext) { - return EnumerableEx.Retry(source, retryCount); - } -#pragma warning restore 1591 - - /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop condition holds. - /// - /// Result sequence element type. - /// Query provider. - /// Loop condition. - /// Sequence to repeat while the condition evaluates true. - /// Sequence generated by repeating the given sequence while the condition evaluates to true. - public static IQueryable While(this IQueryProvider provider, Expression> condition, IEnumerable source) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); if (source == null) throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.While(default(IQueryProvider), default(Expression>), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - condition, - GetSourceExpression(source) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Do__TSource__2__0(typeof(TSource)), source.Expression, onNext)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable While(Func condition, IEnumerable source) + public static IEnumerable Do(IEnumerable source, Action onNext) { - return EnumerableEx.While(condition, source).AsQueryable(); + return EnumerableEx.Do(source, onNext); } #pragma warning restore 1591 - /// - /// Returns an enumerable sequence based on the evaluation result of the given condition. - /// - /// Result sequence element type. - /// Query provider. - /// Condition to evaluate. - /// Sequence to return in case the condition evaluates true. - /// Sequence to return in case the condition evaluates false. - /// Either of the two input sequences based on the result of evaluating the condition. - public static IQueryable If(this IQueryProvider provider, Expression> condition, IEnumerable thenSource, IEnumerable elseSource) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (thenSource == null) - throw new ArgumentNullException(nameof(thenSource)); - if (elseSource == null) - throw new ArgumentNullException(nameof(elseSource)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.If(default(IQueryProvider), default(Expression>), default(IEnumerable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - condition, - GetSourceExpression(thenSource), - GetSourceExpression(elseSource) - ) - ); - } + private static MethodInfo s_Do__TSource__2__1; + + private static MethodInfo Do__TSource__2__1(Type TSource) => + (s_Do__TSource__2__1 ?? + (s_Do__TSource__2__1 = new Func, IObserver, IQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable If(Func condition, IEnumerable thenSource, IEnumerable elseSource) + public static IQueryable Do(this IQueryable source, IObserver observer) { - return EnumerableEx.If(condition, thenSource, elseSource).AsQueryable(); - } -#pragma warning restore 1591 + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (observer == null) + throw new ArgumentNullException(nameof(observer)); - /// - /// Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty sequence. - /// - /// Result sequence element type. - /// Query provider. - /// Condition to evaluate. - /// Sequence to return in case the condition evaluates true. - /// The given input sequence if the condition evaluates true; otherwise, an empty sequence. - public static IQueryable If(this IQueryProvider provider, Expression> condition, IEnumerable thenSource) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (thenSource == null) - throw new ArgumentNullException(nameof(thenSource)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.If(default(IQueryProvider), default(Expression>), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - condition, - GetSourceExpression(thenSource) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Do__TSource__2__1(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable If(Func condition, IEnumerable thenSource) + public static IEnumerable Do(IEnumerable source, IObserver observer) { - return EnumerableEx.If(condition, thenSource).AsQueryable(); + return EnumerableEx.Do(source, observer); } #pragma warning restore 1591 - /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. - /// - /// Result sequence element type. - /// Source sequence to repeat while the condition evaluates true. - /// Loop condition. - /// Sequence generated by repeating the given sequence until the condition evaluates to false. - public static IQueryable DoWhile(this IQueryable source, Expression> condition) + private static MethodInfo s_Do__TSource__3__0; + + private static MethodInfo Do__TSource__3__0(Type TSource) => + (s_Do__TSource__3__0 ?? + (s_Do__TSource__3__0 = new Func, Expression>, Action, IQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Do(this IQueryable source, Expression> onNext, Action onCompleted) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DoWhile(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - source.Expression, - condition - ) - ); + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__0(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DoWhile(IEnumerable source, Func condition) + public static IEnumerable Do(IEnumerable source, Action onNext, Action onCompleted) { - return EnumerableEx.DoWhile(source, condition); + return EnumerableEx.Do(source, onNext, onCompleted); } #pragma warning restore 1591 - /// - /// Returns a sequence from a dictionary based on the result of evaluating a selector function. - /// - /// Type of the selector value. - /// Result sequence element type. - /// Query provider. - /// Selector function used to pick a sequence from the given sources. - /// Dictionary mapping selector values onto resulting sequences. - /// The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. - public static IQueryable Case(this IQueryProvider provider, Expression> selector, IDictionary> sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Case(default(IQueryProvider), default(Expression>), default(IDictionary>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)), -#endif - selector, - Expression.Constant(sources, typeof(IDictionary>)) - ) - ); - } + private static MethodInfo s_Do__TSource__3__1; + + private static MethodInfo Do__TSource__3__1(Type TSource) => + (s_Do__TSource__3__1 ?? + (s_Do__TSource__3__1 = new Func, Expression>, Expression>, IQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Case(Func selector, IDictionary> sources) + public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError) { - return EnumerableEx.Case(selector, sources).AsQueryable(); - } -#pragma warning restore 1591 + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); - /// - /// Returns a sequence from a dictionary based on the result of evaluating a selector function, also specifying a default sequence. - /// - /// Type of the selector value. - /// Result sequence element type. - /// Query provider. - /// Selector function used to pick a sequence from the given sources. - /// Dictionary mapping selector values onto resulting sequences. - /// Default sequence to return in case there's no corresponding source for the computed selector value. - /// The source sequence corresponding with the evaluated selector value; otherwise, the default source. - public static IQueryable Case(this IQueryProvider provider, Expression> selector, IDictionary> sources, IEnumerable defaultSource) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - if (defaultSource == null) - throw new ArgumentNullException(nameof(defaultSource)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Case(default(IQueryProvider), default(Expression>), default(IDictionary>), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)), -#endif - selector, - Expression.Constant(sources, typeof(IDictionary>)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__1(typeof(TSource)), source.Expression, onNext, onError)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Case(Func selector, IDictionary> sources, IEnumerable defaultSource) + public static IEnumerable Do(IEnumerable source, Action onNext, Action onError) { - return EnumerableEx.Case(selector, sources, defaultSource).AsQueryable(); + return EnumerableEx.Do(source, onNext, onError); } #pragma warning restore 1591 - /// - /// Generates a sequence by enumerating a source sequence, mapping its elements on result sequences, and concatenating those sequences. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Query provider. - /// Source sequence. - /// Result selector to evaluate for each iteration over the source. - /// Sequence concatenating the inner sequences that result from evaluating the result selector on elements from the source. - public static IQueryable For(this IQueryProvider provider, IEnumerable source, Expression>> resultSelector) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); + private static MethodInfo s_Do__TSource__4__0; + + private static MethodInfo Do__TSource__4__0(Type TSource) => + (s_Do__TSource__4__0 ?? + (s_Do__TSource__4__0 = new Func, Expression>, Expression>, Action, IQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError, Action onCompleted) + { if (source == null) throw new ArgumentNullException(nameof(source)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.For(default(IQueryProvider), default(IEnumerable), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - GetSourceExpression(source), - resultSelector - ) - ); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + + return source.Provider.CreateQuery(Expression.Call(Do__TSource__4__0(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable For(IEnumerable source, Func> resultSelector) + public static IEnumerable Do(IEnumerable source, Action onNext, Action onError, Action onCompleted) { - return EnumerableEx.For(source, resultSelector).AsQueryable(); + return EnumerableEx.Do(source, onNext, onError, onCompleted); } #pragma warning restore 1591 - /// - /// Concatenates the input sequences. - /// - /// Source sequence element type. - /// Source sequences. - /// Sequence with the elements of the source sequences concatenated. - public static IQueryable Concat(this IQueryable> sources) + private static MethodInfo s_DoWhile__TResult__2__0; + + private static MethodInfo DoWhile__TResult__2__0(Type TResult) => + (s_DoWhile__TResult__2__0 ?? + (s_DoWhile__TResult__2__0 = new Func, Expression>, IQueryable>(DoWhile).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TResult); + + public static IQueryable DoWhile(this IQueryable source, Expression> condition) { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); - return sources.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Concat(default(IQueryable>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - GetSourceExpression(sources) - ) - ); + return source.Provider.CreateQuery(Expression.Call(DoWhile__TResult__2__0(typeof(TResult)), source.Expression, condition)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Concat(IEnumerable> sources) + public static IEnumerable DoWhile(IEnumerable source, Func condition) { - return EnumerableEx.Concat(sources); + return EnumerableEx.DoWhile(source, condition); } #pragma warning restore 1591 - /// - /// Concatenates the input sequences. - /// - /// Source sequence element type. - /// Query provider. - /// Source sequences. - /// Sequence with the elements of the source sequences concatenated. - public static IQueryable Concat(this IQueryProvider provider, params IEnumerable[] sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); + private static MethodInfo s_Expand__TSource__2__0; + + private static MethodInfo Expand__TSource__2__0(Type TSource) => + (s_Expand__TSource__2__0 ?? + (s_Expand__TSource__2__0 = new Func, Expression>>, IQueryable>(Expand).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Expand(this IQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Concat(default(IQueryProvider), default(IEnumerable[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - GetSourceExpression(sources) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Expand__TSource__2__0(typeof(TSource)), source.Expression, selector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Concat(params IEnumerable[] sources) + public static IEnumerable Expand(IEnumerable source, Func> selector) { - return EnumerableEx.Concat(sources).AsQueryable(); + return EnumerableEx.Expand(source, selector); } #pragma warning restore 1591 - /// - /// Projects each element of a sequence to an given sequence and flattens the resulting sequences into one sequence. - /// - /// First source sequence element type. - /// Second source sequence element type. - /// A sequence of values to project. - /// Inner sequence each source sequenec element is projected onto. - /// Sequence flattening the sequences that result from projecting elements in the source sequence. - public static IQueryable SelectMany(this IQueryable source, IEnumerable other) + private static MethodInfo s_Finally__TSource__2__0; + + private static MethodInfo Finally__TSource__2__0(Type TSource) => + (s_Finally__TSource__2__0 ?? + (s_Finally__TSource__2__0 = new Func, Action, IQueryable>(Finally).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Finally(this IQueryable source, Action finallyAction) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (other == null) - throw new ArgumentNullException(nameof(other)); + if (finallyAction == null) + throw new ArgumentNullException(nameof(finallyAction)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.SelectMany(default(IQueryable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), -#endif - source.Expression, - GetSourceExpression(other) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Finally__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable SelectMany(IEnumerable source, IEnumerable other) + public static IEnumerable Finally(IEnumerable source, Action finallyAction) { - return EnumerableEx.SelectMany(source, other); + return EnumerableEx.Finally(source, finallyAction); } #pragma warning restore 1591 - /// - /// Hides the enumerable sequence object identity. - /// - /// Source sequence element type. - /// Source sequence. - /// Enumerable sequence with the same behavior as the original, but hiding the source object identity. - /// AsQueryable doesn't hide the object identity, and simply acts as a cast to the IQueryable<TSource> interface. + private static MethodInfo s_Hide__TSource__1__0; + + private static MethodInfo Hide__TSource__1__0(Type TSource) => + (s_Hide__TSource__1__0 ?? + (s_Hide__TSource__1__0 = new Func, IQueryable>(Hide).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IQueryable Hide(this IQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Hide(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); + return source.Provider.CreateQuery(Expression.Call(Hide__TSource__1__0(typeof(TSource)), source.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Hide(IEnumerable source) { - return EnumerableEx.Hide(source); + return EnumerableEx.Hide(source); } #pragma warning restore 1591 - /// - /// Lazily invokes an action for each value in the sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext) + private static MethodInfo s_IgnoreElements__TSource__1__0; + + private static MethodInfo IgnoreElements__TSource__1__0(Type TSource) => + (s_IgnoreElements__TSource__1__0 ?? + (s_IgnoreElements__TSource__1__0 = new Func, IQueryable>(IgnoreElements).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable IgnoreElements(this IQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext - ) - ); + return source.Provider.CreateQuery(Expression.Call(IgnoreElements__TSource__1__0(typeof(TSource)), source.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext) + public static IEnumerable IgnoreElements(IEnumerable source) { - return EnumerableEx.Do(source, onNext); + return EnumerableEx.IgnoreElements(source); } #pragma warning restore 1591 - /// - /// Lazily invokes an action for each value in the sequence, and executes an action for successful termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Action to invoke on successful termination of the sequence. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext, Expression onCompleted) + private static MethodInfo s_IsEmpty__TSource__1__0; + + private static MethodInfo IsEmpty__TSource__1__0(Type TSource) => + (s_IsEmpty__TSource__1__0 ?? + (s_IsEmpty__TSource__1__0 = new Func, bool>(IsEmpty).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static bool IsEmpty(this IQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext, - onCompleted - ) - ); + return source.Provider.Execute(Expression.Call(IsEmpty__TSource__1__0(typeof(TSource)), source.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext, Action onCompleted) + public static bool IsEmpty(IEnumerable source) { - return EnumerableEx.Do(source, onNext, onCompleted); + return EnumerableEx.IsEmpty(source); } #pragma warning restore 1591 - /// - /// Lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Action to invoke on exceptional termination of the sequence. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError) + private static MethodInfo s_Max__TSource__2__0; + + private static MethodInfo Max__TSource__2__0(Type TSource) => + (s_Max__TSource__2__0 ?? + (s_Max__TSource__2__0 = new Func, IComparer, TSource>(Max).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static TSource Max(this IQueryable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext, - onError - ) - ); + return source.Provider.Execute(Expression.Call(Max__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext, Action onError) + public static TSource Max(IEnumerable source, IComparer comparer) { - return EnumerableEx.Do(source, onNext, onError); + return EnumerableEx.Max(source, comparer); } #pragma warning restore 1591 - /// - /// Lazily invokes an action for each value in the sequence, and executes an action upon successful or exceptional termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Action to invoke on exceptional termination of the sequence. - /// Action to invoke on successful termination of the sequence. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError, Expression onCompleted) + private static MethodInfo s_MaxBy__TSource_TKey__2__0; + + private static MethodInfo MaxBy__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_MaxBy__TSource_TKey__2__0 ?? + (s_MaxBy__TSource_TKey__2__0 = new Func, Expression>, IList>(MaxBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + + public static IList MaxBy(this IQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression>), default(Expression))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext, - onError, - onCompleted - ) - ); + return source.Provider.Execute>(Expression.Call(MaxBy__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext, Action onError, Action onCompleted) + public static IList MaxBy(IEnumerable source, Func keySelector) { - return EnumerableEx.Do(source, onNext, onError, onCompleted); + return EnumerableEx.MaxBy(source, keySelector); } #pragma warning restore 1591 - /// - /// Lazily invokes observer methods for each value in the sequence, and upon successful or exceptional termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Observer to invoke notification calls on. - /// Sequence exhibiting the side-effects of observer method invocation upon enumeration. - public static IQueryable Do(this IQueryable source, IObserver observer) + private static MethodInfo s_MaxBy__TSource_TKey__3__0; + + private static MethodInfo MaxBy__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_MaxBy__TSource_TKey__3__0 ?? + (s_MaxBy__TSource_TKey__3__0 = new Func, Expression>, IComparer, IList>(MaxBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + + public static IList MaxBy(this IQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (observer == null) - throw new ArgumentNullException(nameof(observer)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(IObserver))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(observer, typeof(IObserver)) - ) - ); + return source.Provider.Execute>(Expression.Call(MaxBy__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, IObserver observer) + public static IList MaxBy(IEnumerable source, Func keySelector, IComparer comparer) { - return EnumerableEx.Do(source, observer); + return EnumerableEx.MaxBy(source, keySelector, comparer); } #pragma warning restore 1591 - /// - /// Generates a sequence of non-overlapping adjacent buffers over the source sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// Number of elements for allocated buffers. - /// Sequence of buffers containing source sequence elements. - public static IQueryable> Buffer(this IQueryable source, int count) + private static MethodInfo s_Memoize__TSource_TResult__2__0; + + private static MethodInfo Memoize__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_Memoize__TSource_TResult__2__0 ?? + (s_Memoize__TSource_TResult__2__0 = new Func, Expression, IEnumerable>>, IQueryable>(Memoize).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + + public static IQueryable Memoize(this IQueryable source, Expression, IEnumerable>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Provider.CreateQuery>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Buffer(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Memoize__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable> Buffer(IEnumerable source, int count) + public static IEnumerable Memoize(IEnumerable source, Func, IEnumerable> selector) { - return EnumerableEx.Buffer(source, count); + return EnumerableEx.Memoize(source, selector); } #pragma warning restore 1591 - /// - /// Generates a sequence of buffers over the source sequence, with specified length and possible overlap. - /// - /// Source sequence element type. - /// Source sequence. - /// Number of elements for allocated buffers. - /// Number of elements to skip between the start of consecutive buffers. - /// Sequence of buffers containing source sequence elements. - public static IQueryable> Buffer(this IQueryable source, int count, int skip) + private static MethodInfo s_Memoize__TSource_TResult__3__0; + + private static MethodInfo Memoize__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_Memoize__TSource_TResult__3__0 ?? + (s_Memoize__TSource_TResult__3__0 = new Func, int, Expression, IEnumerable>>, IQueryable>(Memoize).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + + public static IQueryable Memoize(this IQueryable source, int readerCount, Expression, IEnumerable>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Provider.CreateQuery>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Buffer(default(IQueryable), default(int), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)), - Expression.Constant(skip, typeof(int)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Memoize__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, Expression.Constant(readerCount, typeof(int)), selector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable> Buffer(IEnumerable source, int count, int skip) + public static IEnumerable Memoize(IEnumerable source, int readerCount, Func, IEnumerable> selector) { - return EnumerableEx.Buffer(source, count, skip); + return EnumerableEx.Memoize(source, readerCount, selector); } #pragma warning restore 1591 - /// - /// Ignores all elements in the source sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// Source sequence without its elements. - public static IQueryable IgnoreElements(this IQueryable source) + private static MethodInfo s_Min__TSource__2__0; + + private static MethodInfo Min__TSource__2__0(Type TSource) => + (s_Min__TSource__2__0 ?? + (s_Min__TSource__2__0 = new Func, IComparer, TSource>(Min).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static TSource Min(this IQueryable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.IgnoreElements(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); + return source.Provider.Execute(Expression.Call(Min__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable IgnoreElements(IEnumerable source) + public static TSource Min(IEnumerable source, IComparer comparer) { - return EnumerableEx.IgnoreElements(source); + return EnumerableEx.Min(source, comparer); } #pragma warning restore 1591 - /// - /// Returns elements with a distinct key value by using the default equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Sequence that contains the elements from the source sequence with distinct key values. - public static IQueryable Distinct(this IQueryable source, Expression> keySelector) + private static MethodInfo s_MinBy__TSource_TKey__2__0; + + private static MethodInfo MinBy__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_MinBy__TSource_TKey__2__0 ?? + (s_MinBy__TSource_TKey__2__0 = new Func, Expression>, IList>(MinBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + + public static IList MinBy(this IQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Distinct(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); + return source.Provider.Execute>(Expression.Call(MinBy__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Distinct(IEnumerable source, Func keySelector) + public static IList MinBy(IEnumerable source, Func keySelector) { - return EnumerableEx.Distinct(source, keySelector); + return EnumerableEx.MinBy(source, keySelector); } #pragma warning restore 1591 - /// - /// Returns elements with a distinct key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Comparer used to compare key values. - /// Sequence that contains the elements from the source sequence with distinct key values. - public static IQueryable Distinct(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) + private static MethodInfo s_MinBy__TSource_TKey__3__0; + + private static MethodInfo MinBy__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_MinBy__TSource_TKey__3__0 ?? + (s_MinBy__TSource_TKey__3__0 = new Func, Expression>, IComparer, IList>(MinBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + + public static IList MinBy(this IQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1808,291 +744,181 @@ public static IQueryable Distinct(this IQueryable( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Distinct(default(IQueryable), default(Expression>), default(IEqualityComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IEqualityComparer)) - ) - ); + return source.Provider.Execute>(Expression.Call(MinBy__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Distinct(IEnumerable source, Func keySelector, IEqualityComparer comparer) + public static IList MinBy(IEnumerable source, Func keySelector, IComparer comparer) { - return EnumerableEx.Distinct(source, keySelector, comparer); + return EnumerableEx.MinBy(source, keySelector, comparer); } #pragma warning restore 1591 - /// - /// Returns consecutive distinct elements by using the default equality comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source) + private static MethodInfo s_OnErrorResumeNext__TSource__1__0; + + private static MethodInfo OnErrorResumeNext__TSource__1__0(Type TSource) => + (s_OnErrorResumeNext__TSource__1__0 ?? + (s_OnErrorResumeNext__TSource__1__0 = new Func>, IQueryable>(OnErrorResumeNext).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable OnErrorResumeNext(this IQueryable> sources) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); + return sources.Provider.CreateQuery(Expression.Call(OnErrorResumeNext__TSource__1__0(typeof(TSource)), sources.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source) + public static IEnumerable OnErrorResumeNext(IEnumerable> sources) { - return EnumerableEx.DistinctUntilChanged(source); + return EnumerableEx.OnErrorResumeNext(sources); } #pragma warning restore 1591 - /// - /// Returns consecutive distinct elements by using the specified equality comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to compare values. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source, IEqualityComparer comparer) + private static MethodInfo s_OnErrorResumeNext__TSource__2__0; + + private static MethodInfo OnErrorResumeNext__TSource__2__0(Type TSource) => + (s_OnErrorResumeNext__TSource__2__0 ?? + (s_OnErrorResumeNext__TSource__2__0 = new Func, IEnumerable, IQueryable>(OnErrorResumeNext).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable OnErrorResumeNext(this IQueryable first, IEnumerable second) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(IEqualityComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(comparer, typeof(IEqualityComparer)) - ) - ); + return first.Provider.CreateQuery(Expression.Call(OnErrorResumeNext__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source, IEqualityComparer comparer) + public static IEnumerable OnErrorResumeNext(IEnumerable first, IEnumerable second) { - return EnumerableEx.DistinctUntilChanged(source, comparer); + return EnumerableEx.OnErrorResumeNext(first, second); } #pragma warning restore 1591 - /// - /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector) + private static MethodInfo s_Publish__TSource_TResult__2__0; + + private static MethodInfo Publish__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_Publish__TSource_TResult__2__0 ?? + (s_Publish__TSource_TResult__2__0 = new Func, Expression, IEnumerable>>, IQueryable>(Publish).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + + public static IQueryable Publish(this IQueryable source, Expression, IEnumerable>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); + return source.Provider.CreateQuery(Expression.Call(Publish__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector) + public static IEnumerable Publish(IEnumerable source, Func, IEnumerable> selector) { - return EnumerableEx.DistinctUntilChanged(source, keySelector); + return EnumerableEx.Publish(source, selector); } #pragma warning restore 1591 - /// - /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Comparer used to compare key values. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) + private static MethodInfo s_Repeat__TSource__1__0; + + private static MethodInfo Repeat__TSource__1__0(Type TSource) => + (s_Repeat__TSource__1__0 ?? + (s_Repeat__TSource__1__0 = new Func, IQueryable>(Repeat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Repeat(this IQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(Expression>), default(IEqualityComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IEqualityComparer)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Repeat__TSource__1__0(typeof(TSource)), source.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector, IEqualityComparer comparer) + public static IEnumerable Repeat(IEnumerable source) { - return EnumerableEx.DistinctUntilChanged(source, keySelector, comparer); + return EnumerableEx.Repeat(source); } #pragma warning restore 1591 - /// - /// Expands the sequence by recursively applying a selector function. - /// - /// Source sequence element type. - /// Source sequence. - /// Selector function to retrieve the next sequence to expand. - /// Sequence with results from the recursive expansion of the source sequence. - public static IQueryable Expand(this IQueryable source, Expression>> selector) + private static MethodInfo s_Repeat__TSource__2__0; + + private static MethodInfo Repeat__TSource__2__0(Type TSource) => + (s_Repeat__TSource__2__0 ?? + (s_Repeat__TSource__2__0 = new Func, int, IQueryable>(Repeat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Repeat(this IQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Expand(default(IQueryable), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - selector - ) - ); + return source.Provider.CreateQuery(Expression.Call(Repeat__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Expand(IEnumerable source, Func> selector) + public static IEnumerable Repeat(IEnumerable source, int count) { - return EnumerableEx.Expand(source, selector); + return EnumerableEx.Repeat(source, count); } #pragma warning restore 1591 - /// - /// Returns the source sequence prefixed with the specified value. - /// - /// Source sequence element type. - /// Source sequence. - /// Values to prefix the sequence with. - /// Sequence starting with the specified prefix value, followed by the source sequence. - public static IQueryable StartWith(this IQueryable source, params TSource[] values) + private static MethodInfo s_Retry__TSource__1__0; + + private static MethodInfo Retry__TSource__1__0(Type TSource) => + (s_Retry__TSource__1__0 ?? + (s_Retry__TSource__1__0 = new Func, IQueryable>(Retry).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Retry(this IQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.StartWith(default(IQueryable), default(TSource[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(values, typeof(TSource[])) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Retry__TSource__1__0(typeof(TSource)), source.Expression)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable StartWith(IEnumerable source, params TSource[] values) + public static IEnumerable Retry(IEnumerable source) { - return EnumerableEx.StartWith(source, values); + return EnumerableEx.Retry(source); } #pragma warning restore 1591 - /// - /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. - /// - /// Source sequence element type. - /// Accumulation type. - /// Source sequence. - /// Accumulator seed value. - /// Accumulation function to apply to the current accumulation value and each element of the sequence. - /// Sequence with all intermediate accumulation values resulting from scanning the sequence. - public static IQueryable Scan(this IQueryable source, TAccumulate seed, Expression> accumulator) + private static MethodInfo s_Retry__TSource__2__0; + + private static MethodInfo Retry__TSource__2__0(Type TSource) => + (s_Retry__TSource__2__0 ?? + (s_Retry__TSource__2__0 = new Func, int, IQueryable>(Retry).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable Retry(this IQueryable source, int retryCount) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Scan(default(IQueryable), default(TAccumulate), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), -#endif - source.Expression, - Expression.Constant(seed, typeof(TAccumulate)), - accumulator - ) - ); + return source.Provider.CreateQuery(Expression.Call(Retry__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Scan(IEnumerable source, TAccumulate seed, Func accumulator) + public static IEnumerable Retry(IEnumerable source, int retryCount) { - return EnumerableEx.Scan(source, seed, accumulator); + return EnumerableEx.Retry(source, retryCount); } #pragma warning restore 1591 - /// - /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. - /// - /// Source sequence element type. - /// Source sequence. - /// Accumulation function to apply to the current accumulation value and each element of the sequence. - /// Sequence with all intermediate accumulation values resulting from scanning the sequence. + private static MethodInfo s_Scan__TSource__2__0; + + private static MethodInfo Scan__TSource__2__0(Type TSource) => + (s_Scan__TSource__2__0 ?? + (s_Scan__TSource__2__0 = new Func, Expression>, IQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IQueryable Scan(this IQueryable source, Expression> accumulator) { if (source == null) @@ -2100,271 +926,156 @@ public static IQueryable Scan(this IQueryable source, if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Scan(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - accumulator - ) - ); + return source.Provider.CreateQuery(Expression.Call(Scan__TSource__2__0(typeof(TSource)), source.Expression, accumulator)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Scan(IEnumerable source, Func accumulator) { - return EnumerableEx.Scan(source, accumulator); + return EnumerableEx.Scan(source, accumulator); } #pragma warning restore 1591 - /// - /// Returns a specified number of contiguous elements from the end of the sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// The number of elements to take from the end of the sequence. - /// Sequence with the specified number of elements counting from the end of the source sequence. - public static IQueryable TakeLast(this IQueryable source, int count) + private static MethodInfo s_Scan__TSource_TAccumulate__3__0; + + private static MethodInfo Scan__TSource_TAccumulate__3__0(Type TSource, Type TAccumulate) => + (s_Scan__TSource_TAccumulate__3__0 ?? + (s_Scan__TSource_TAccumulate__3__0 = new Func, TAccumulate, Expression>, IQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + + public static IQueryable Scan(this IQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.TakeLast(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(Scan__TSource_TAccumulate__3__0(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable TakeLast(IEnumerable source, int count) + public static IEnumerable Scan(IEnumerable source, TAccumulate seed, Func accumulator) { -#if REFERENCE_ASSEMBLY - return null; -#else - return EnumerableEx.TakeLast(source, count); -#endif + return EnumerableEx.Scan(source, seed, accumulator); } #pragma warning restore 1591 - /// - /// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. - /// - /// Source sequence element type. - /// Source sequence. - /// The number of elements to skip from the end of the sequence before returning the remaining elements. - /// Sequence bypassing the specified number of elements counting from the end of the source sequence. - public static IQueryable SkipLast(this IQueryable source, int count) + private static MethodInfo s_SelectMany__TSource_TOther__2__0; + + private static MethodInfo SelectMany__TSource_TOther__2__0(Type TSource, Type TOther) => + (s_SelectMany__TSource_TOther__2__0 ?? + (s_SelectMany__TSource_TOther__2__0 = new Func, IEnumerable, IQueryable>(SelectMany).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TOther); + + public static IQueryable SelectMany(this IQueryable source, IEnumerable other) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (other == null) + throw new ArgumentNullException(nameof(other)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.SkipLast(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(SelectMany__TSource_TOther__2__0(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable SkipLast(IEnumerable source, int count) + public static IEnumerable SelectMany(IEnumerable source, IEnumerable other) { -#if REFERENCE_ASSEMBLY - return null; -#else - return EnumerableEx.SkipLast(source, count); -#endif + return EnumerableEx.SelectMany(source, other); } #pragma warning restore 1591 - /// - /// Repeats and concatenates the source sequence infinitely. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence obtained by concatenating the source sequence to itself infinitely. - public static IQueryable Repeat(this IQueryable source) + private static MethodInfo s_Share__TSource_TResult__2__0; + + private static MethodInfo Share__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_Share__TSource_TResult__2__0 ?? + (s_Share__TSource_TResult__2__0 = new Func, Expression, IEnumerable>>, IQueryable>(Share).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + + public static IQueryable Share(this IQueryable source, Expression, IEnumerable>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); + return source.Provider.CreateQuery(Expression.Call(Share__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Repeat(IEnumerable source) + public static IEnumerable Share(IEnumerable source, Func, IEnumerable> selector) { - return EnumerableEx.Repeat(source); + return EnumerableEx.Share(source, selector); } #pragma warning restore 1591 - /// - /// Repeats and concatenates the source sequence the given number of times. - /// - /// Source sequence element type. - /// Source sequence. - /// Number of times to repeat the source sequence. - /// Sequence obtained by concatenating the source sequence to itself the specified number of times. - public static IQueryable Repeat(this IQueryable source, int count) + private static MethodInfo s_SkipLast__TSource__2__0; + + private static MethodInfo SkipLast__TSource__2__0(Type TSource) => + (s_SkipLast__TSource__2__0 ?? + (s_SkipLast__TSource__2__0 = new Func, int, IQueryable>(SkipLast).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable SkipLast(this IQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(SkipLast__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Repeat(IEnumerable source, int count) + public static IEnumerable SkipLast(IEnumerable source, int count) { - return EnumerableEx.Repeat(source, count); + return EnumerableEx.SkipLast(source, count); } #pragma warning restore 1591 - /// - /// Returns a sequence with no elements. - /// - /// Result sequence element type. - /// Query provider. - /// Sequence with no elements. - public static IQueryable Empty(this IQueryProvider provider) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Empty(default(IQueryProvider))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)) - ) - ); - } + private static MethodInfo s_StartWith__TSource__2__0; + + private static MethodInfo StartWith__TSource__2__0(Type TSource) => + (s_StartWith__TSource__2__0 ?? + (s_StartWith__TSource__2__0 = new Func, TSource[], IQueryable>(StartWith).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Empty() + public static IQueryable StartWith(this IQueryable source, params TSource[] values) { - return Enumerable.Empty().AsQueryable(); - } -#pragma warning restore 1591 + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (values == null) + throw new ArgumentNullException(nameof(values)); - /// - /// Generates a sequence of integral numbers within a specified range. - /// - /// Query provider. - /// The value of the first integer in the sequence. - /// The number of sequential integers to generate. - /// Sequence that contains a range of sequential integral numbers. - public static IQueryable Range(this IQueryProvider provider, int start, int count) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Range(default(IQueryProvider), default(int), default(int))), -#else - (MethodInfo)MethodInfo.GetCurrentMethod(), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(start, typeof(int)), - Expression.Constant(count, typeof(int)) - ) - ); + return source.Provider.CreateQuery(Expression.Call(StartWith__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Range(int start, int count) + public static IEnumerable StartWith(IEnumerable source, TSource[] values) { - return Enumerable.Range(start, count).AsQueryable(); + return EnumerableEx.StartWith(source, values); } #pragma warning restore 1591 - /// - /// Generates a sequence that contains one repeated value. - /// - /// Result sequence element type. - /// Query provider. - /// The value to be repeated. - /// The number of times to repeat the value in the generated sequence. - /// Sequence that contains a repeated value. - public static IQueryable Repeat(this IQueryProvider provider, TResult element, int count) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryProvider), default(TResult), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(element, typeof(TResult)), - Expression.Constant(count, typeof(int)) - ) - ); + private static MethodInfo s_TakeLast__TSource__2__0; + + private static MethodInfo TakeLast__TSource__2__0(Type TSource) => + (s_TakeLast__TSource__2__0 ?? + (s_TakeLast__TSource__2__0 = new Func, int, IQueryable>(TakeLast).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + + public static IQueryable TakeLast(this IQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery(Expression.Call(TakeLast__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } #pragma warning disable 1591 [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Repeat(TResult element, int count) + public static IEnumerable TakeLast(IEnumerable source, int count) { - return EnumerableEx.Repeat(element, count).AsQueryable(); + return EnumerableEx.TakeLast(source, count); } #pragma warning restore 1591 + } } diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.tt new file mode 100644 index 0000000000..b5ea3bfa4d --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.tt @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="$(ProjectDir)\..\System.Interactive\bin\$(Configuration)\net45\System.Interactive.dll" #> +<#@ output extension=".cs" #> +<# +var enumerableType = typeof(EnumerableEx); +var className = "QueryableEx"; +var nullableParameterNames = new string[0] { }; // TODO: Add comparer +var exclude = new[] { "ForEach" }; +#> +<#@ include file="$(SolutionDir)\QueryableGenerator.t4" #> diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs index e9cdbc678b..6e1af21f1e 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs @@ -187,5 +187,12 @@ internal static MethodInfo InfoOf(Expression> f) { return ((MethodCallExpression)f.Body).Method; } + + private sealed class TSource { } + private sealed class TResult { } + private sealed class TAccumulate { } + private sealed class TOther { } + private sealed class TKey { } + private sealed class TException : Exception { } } } From 978ffe633f0cbe27732b710692bf6e22e52c7170 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 10:24:54 -0700 Subject: [PATCH 2/8] Remove crippled reflection support. --- .../Reflection.cs | 55 ------------------- .../System.Interactive.Providers.csproj | 4 -- 2 files changed, 59 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Providers/Reflection.cs diff --git a/Ix.NET/Source/System.Interactive.Providers/Reflection.cs b/Ix.NET/Source/System.Interactive.Providers/Reflection.cs deleted file mode 100644 index 2978a651cb..0000000000 --- a/Ix.NET/Source/System.Interactive.Providers/Reflection.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -#if CRIPPLED_REFLECTION -using System.Linq; -using System.Reflection; - -namespace System.Reflection -{ - [Flags] - internal enum BindingFlags - { - Instance = 4, - Static = 8, - Public = 16, - NonPublic = 32, - } -} - -namespace System -{ - internal static class TypeExtensions - { - public static bool IsAssignableFrom(this Type t1, Type t2) - { - return t1.GetTypeInfo().IsAssignableFrom(t2.GetTypeInfo()); - } - - public static MethodInfo[] GetMethods(this Type t, BindingFlags flags) - { - return t.GetTypeInfo().DeclaredMethods.Where(m => IsVisible(m, flags)).ToArray(); - } - - private static bool IsVisible(MethodInfo method, BindingFlags flags) - { - if ((flags & BindingFlags.Public) != 0 != method.IsPublic) - { - return false; - } - - if ((flags & BindingFlags.NonPublic) == 0 && !method.IsPublic) - { - return false; - } - - if ((flags & BindingFlags.Static) != 0 != method.IsStatic) - { - return false; - } - - return true; - } - } -} -#endif diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 69afb32308..738d9b3656 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -7,10 +7,6 @@ Ix;Interactive;Extensions;Enumerable - - $(DefineConstants);CRIPPLED_REFLECTION - - From b930a13461a65a3e3b26d33ce78958247ac9ae7a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 10:28:57 -0700 Subject: [PATCH 3/8] Aim a little higher with targets. --- .../System.Interactive.Providers.csproj | 6 +----- Ix.NET/Source/System.Interactive/System.Interactive.csproj | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 738d9b3656..de15b3c6d5 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. Interactive Extensions - Providers Library - net45;netstandard1.0;netstandard2.0 + net461;netstandard2.0 Ix;Interactive;Extensions;Enumerable @@ -16,10 +16,6 @@ - - - - QueryableEx.Generated.cs diff --git a/Ix.NET/Source/System.Interactive/System.Interactive.csproj b/Ix.NET/Source/System.Interactive/System.Interactive.csproj index f3effe33a5..38d055c43a 100644 --- a/Ix.NET/Source/System.Interactive/System.Interactive.csproj +++ b/Ix.NET/Source/System.Interactive/System.Interactive.csproj @@ -4,7 +4,7 @@ Interactive Extensions Main Library used to express queries over enumerable sequences. Interactive Extensions - Main Library Microsoft - net45;netstandard1.0;netstandard2.0 + net461;netstandard2.0 Ix;Interactive;Extensions;Enumerable From bb813f3d93259705945e88212a980a5f4361c2b4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 11:19:44 -0700 Subject: [PATCH 4/8] Clean up build flavors. --- .../System.Interactive.Providers.Ref.csproj | 11 +---------- .../System.Interactive.Ref.csproj | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj index 020dd5331c..f12a1f4d8b 100644 --- a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj +++ b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj @@ -3,14 +3,10 @@ Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. Interactive Extensions - Providers Library - netstandard1.0;netcoreapp2.0;netstandard2.1 + net461;netstandard2.0 Ix;Interactive;Extensions;Enumerable - - $(DefineConstants);CRIPPLED_REFLECTION - - @@ -18,10 +14,5 @@ - - - - - diff --git a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj index 7237c5a159..ed48101d4b 100644 --- a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj +++ b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj @@ -4,7 +4,7 @@ Interactive Extensions Main Library used to express queries over enumerable sequences. Interactive Extensions - Main Library Microsoft - netstandard1.0;netcoreapp2.0;netstandard2.1 + net461;netstandard2.0 Ix;Interactive;Extensions;Enumerable From 6dbab988abcaebcd4512a4c36483522d0375d38b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 12:07:34 -0700 Subject: [PATCH 5/8] Revert "Remove crippled reflection support." This reverts commit 978ffe633f0cbe27732b710692bf6e22e52c7170. --- .../Reflection.cs | 55 +++++++++++++++++++ .../System.Interactive.Providers.csproj | 4 ++ 2 files changed, 59 insertions(+) create mode 100644 Ix.NET/Source/System.Interactive.Providers/Reflection.cs diff --git a/Ix.NET/Source/System.Interactive.Providers/Reflection.cs b/Ix.NET/Source/System.Interactive.Providers/Reflection.cs new file mode 100644 index 0000000000..2978a651cb --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Providers/Reflection.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +#if CRIPPLED_REFLECTION +using System.Linq; +using System.Reflection; + +namespace System.Reflection +{ + [Flags] + internal enum BindingFlags + { + Instance = 4, + Static = 8, + Public = 16, + NonPublic = 32, + } +} + +namespace System +{ + internal static class TypeExtensions + { + public static bool IsAssignableFrom(this Type t1, Type t2) + { + return t1.GetTypeInfo().IsAssignableFrom(t2.GetTypeInfo()); + } + + public static MethodInfo[] GetMethods(this Type t, BindingFlags flags) + { + return t.GetTypeInfo().DeclaredMethods.Where(m => IsVisible(m, flags)).ToArray(); + } + + private static bool IsVisible(MethodInfo method, BindingFlags flags) + { + if ((flags & BindingFlags.Public) != 0 != method.IsPublic) + { + return false; + } + + if ((flags & BindingFlags.NonPublic) == 0 && !method.IsPublic) + { + return false; + } + + if ((flags & BindingFlags.Static) != 0 != method.IsStatic) + { + return false; + } + + return true; + } + } +} +#endif diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index de15b3c6d5..9527431f1d 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -7,6 +7,10 @@ Ix;Interactive;Extensions;Enumerable + + $(DefineConstants);CRIPPLED_REFLECTION + + From c00905ae0e04d1bf536e76180a20b1bbfec9812d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 12:07:53 -0700 Subject: [PATCH 6/8] Revert "Aim a little higher with targets." This reverts commit b930a13461a65a3e3b26d33ce78958247ac9ae7a. --- .../System.Interactive.Providers.csproj | 6 +++++- Ix.NET/Source/System.Interactive/System.Interactive.csproj | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 9527431f1d..69afb32308 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. Interactive Extensions - Providers Library - net461;netstandard2.0 + net45;netstandard1.0;netstandard2.0 Ix;Interactive;Extensions;Enumerable @@ -20,6 +20,10 @@ + + + + QueryableEx.Generated.cs diff --git a/Ix.NET/Source/System.Interactive/System.Interactive.csproj b/Ix.NET/Source/System.Interactive/System.Interactive.csproj index 38d055c43a..f3effe33a5 100644 --- a/Ix.NET/Source/System.Interactive/System.Interactive.csproj +++ b/Ix.NET/Source/System.Interactive/System.Interactive.csproj @@ -4,7 +4,7 @@ Interactive Extensions Main Library used to express queries over enumerable sequences. Interactive Extensions - Main Library Microsoft - net461;netstandard2.0 + net45;netstandard1.0;netstandard2.0 Ix;Interactive;Extensions;Enumerable From 033bb8a798b35647e6c97e54c98370ae92b18015 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 12:08:05 -0700 Subject: [PATCH 7/8] Revert "Clean up build flavors." This reverts commit bb813f3d93259705945e88212a980a5f4361c2b4. --- .../System.Interactive.Providers.Ref.csproj | 11 ++++++++++- .../System.Interactive.Ref.csproj | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj index f12a1f4d8b..020dd5331c 100644 --- a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj +++ b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj @@ -3,10 +3,14 @@ Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. Interactive Extensions - Providers Library - net461;netstandard2.0 + netstandard1.0;netcoreapp2.0;netstandard2.1 Ix;Interactive;Extensions;Enumerable + + $(DefineConstants);CRIPPLED_REFLECTION + + @@ -14,5 +18,10 @@ + + + + + diff --git a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj index ed48101d4b..7237c5a159 100644 --- a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj +++ b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj @@ -4,7 +4,7 @@ Interactive Extensions Main Library used to express queries over enumerable sequences. Interactive Extensions - Main Library Microsoft - net461;netstandard2.0 + netstandard1.0;netcoreapp2.0;netstandard2.1 Ix;Interactive;Extensions;Enumerable From 500256dd3ca352b38a9077a81c229efb3b539be4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 28 May 2019 12:23:03 -0700 Subject: [PATCH 8/8] Support reference assemblies. --- Ix.NET/Source/QueryableGenerator.t4 | 4 + .../System/Linq/QueryableEx.Generated.cs | 180 ++++++++++++++++++ 2 files changed, 184 insertions(+) diff --git a/Ix.NET/Source/QueryableGenerator.t4 b/Ix.NET/Source/QueryableGenerator.t4 index ded859ba2e..4a740bc656 100644 --- a/Ix.NET/Source/QueryableGenerator.t4 +++ b/Ix.NET/Source/QueryableGenerator.t4 @@ -334,7 +334,11 @@ if (any) [EditorBrowsable(EditorBrowsableState.Never)] public static <#=toCSharp(m.ReturnType)#> <#=name#>(<#=string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name))#>)<#=constraints#> { +#if REFERENCE_ASSEMBLY + return default; +#else return <#=enumerableType.Name#>.<#=name#>(<#=string.Join(", ", m.GetParameters().Select(p => p.Name))#>); +#endif } #pragma warning restore 1591 diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs index a975bcedd2..d51292f1a2 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -29,7 +29,11 @@ public static IQueryable> Buffer(this IQueryable> Buffer(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Buffer(source, count); +#endif } #pragma warning restore 1591 @@ -51,7 +55,11 @@ public static IQueryable> Buffer(this IQueryable> Buffer(IEnumerable source, int count, int skip) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Buffer(source, count, skip); +#endif } #pragma warning restore 1591 @@ -73,7 +81,11 @@ public static IQueryable Catch(this IQueryable Catch(IEnumerable> sources) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Catch(sources); +#endif } #pragma warning restore 1591 @@ -97,7 +109,11 @@ public static IQueryable Catch(this IQueryable first, [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Catch(IEnumerable first, IEnumerable second) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Catch(first, second); +#endif } #pragma warning restore 1591 @@ -121,7 +137,11 @@ public static IQueryable Catch(this IQueryable Catch(IEnumerable source, Func> handler) where TException : Exception { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Catch(source, handler); +#endif } #pragma warning restore 1591 @@ -143,7 +163,11 @@ public static IQueryable Concat(this IQueryable Concat(IEnumerable> sources) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Concat(sources); +#endif } #pragma warning restore 1591 @@ -167,7 +191,11 @@ public static IQueryable Distinct(this IQueryable Distinct(IEnumerable source, Func keySelector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Distinct(source, keySelector); +#endif } #pragma warning restore 1591 @@ -193,7 +221,11 @@ public static IQueryable Distinct(this IQueryable Distinct(IEnumerable source, Func keySelector, IEqualityComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Distinct(source, keySelector, comparer); +#endif } #pragma warning restore 1591 @@ -215,7 +247,11 @@ public static IQueryable DistinctUntilChanged(this IQueryable< [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DistinctUntilChanged(IEnumerable source) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.DistinctUntilChanged(source); +#endif } #pragma warning restore 1591 @@ -239,7 +275,11 @@ public static IQueryable DistinctUntilChanged(this IQueryable< [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DistinctUntilChanged(IEnumerable source, IEqualityComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.DistinctUntilChanged(source, comparer); +#endif } #pragma warning restore 1591 @@ -263,7 +303,11 @@ public static IQueryable DistinctUntilChanged(this IQuer [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.DistinctUntilChanged(source, keySelector); +#endif } #pragma warning restore 1591 @@ -289,7 +333,11 @@ public static IQueryable DistinctUntilChanged(this IQuer [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector, IEqualityComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.DistinctUntilChanged(source, keySelector, comparer); +#endif } #pragma warning restore 1591 @@ -313,7 +361,11 @@ public static IQueryable Do(this IQueryable source, E [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Do(IEnumerable source, Action onNext) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Do(source, onNext); +#endif } #pragma warning restore 1591 @@ -337,7 +389,11 @@ public static IQueryable Do(this IQueryable source, I [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Do(IEnumerable source, IObserver observer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Do(source, observer); +#endif } #pragma warning restore 1591 @@ -363,7 +419,11 @@ public static IQueryable Do(this IQueryable source, E [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Do(IEnumerable source, Action onNext, Action onCompleted) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Do(source, onNext, onCompleted); +#endif } #pragma warning restore 1591 @@ -389,7 +449,11 @@ public static IQueryable Do(this IQueryable source, E [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Do(IEnumerable source, Action onNext, Action onError) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Do(source, onNext, onError); +#endif } #pragma warning restore 1591 @@ -417,7 +481,11 @@ public static IQueryable Do(this IQueryable source, E [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Do(IEnumerable source, Action onNext, Action onError, Action onCompleted) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Do(source, onNext, onError, onCompleted); +#endif } #pragma warning restore 1591 @@ -441,7 +509,11 @@ public static IQueryable DoWhile(this IQueryable sour [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DoWhile(IEnumerable source, Func condition) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.DoWhile(source, condition); +#endif } #pragma warning restore 1591 @@ -465,7 +537,11 @@ public static IQueryable Expand(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Expand(IEnumerable source, Func> selector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Expand(source, selector); +#endif } #pragma warning restore 1591 @@ -489,7 +565,11 @@ public static IQueryable Finally(this IQueryable sour [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Finally(IEnumerable source, Action finallyAction) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Finally(source, finallyAction); +#endif } #pragma warning restore 1591 @@ -511,7 +591,11 @@ public static IQueryable Hide(this IQueryable source) [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Hide(IEnumerable source) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Hide(source); +#endif } #pragma warning restore 1591 @@ -533,7 +617,11 @@ public static IQueryable IgnoreElements(this IQueryable IgnoreElements(IEnumerable source) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.IgnoreElements(source); +#endif } #pragma warning restore 1591 @@ -555,7 +643,11 @@ public static bool IsEmpty(this IQueryable source) [EditorBrowsable(EditorBrowsableState.Never)] public static bool IsEmpty(IEnumerable source) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.IsEmpty(source); +#endif } #pragma warning restore 1591 @@ -579,7 +671,11 @@ public static TSource Max(this IQueryable source, IComparer(IEnumerable source, IComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Max(source, comparer); +#endif } #pragma warning restore 1591 @@ -603,7 +699,11 @@ public static IList MaxBy(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IList MaxBy(IEnumerable source, Func keySelector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.MaxBy(source, keySelector); +#endif } #pragma warning restore 1591 @@ -629,7 +729,11 @@ public static IList MaxBy(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IList MaxBy(IEnumerable source, Func keySelector, IComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.MaxBy(source, keySelector, comparer); +#endif } #pragma warning restore 1591 @@ -653,7 +757,11 @@ public static IQueryable Memoize(this IQueryable Memoize(IEnumerable source, Func, IEnumerable> selector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Memoize(source, selector); +#endif } #pragma warning restore 1591 @@ -677,7 +785,11 @@ public static IQueryable Memoize(this IQueryable Memoize(IEnumerable source, int readerCount, Func, IEnumerable> selector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Memoize(source, readerCount, selector); +#endif } #pragma warning restore 1591 @@ -701,7 +813,11 @@ public static TSource Min(this IQueryable source, IComparer(IEnumerable source, IComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Min(source, comparer); +#endif } #pragma warning restore 1591 @@ -725,7 +841,11 @@ public static IList MinBy(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IList MinBy(IEnumerable source, Func keySelector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.MinBy(source, keySelector); +#endif } #pragma warning restore 1591 @@ -751,7 +871,11 @@ public static IList MinBy(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IList MinBy(IEnumerable source, Func keySelector, IComparer comparer) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.MinBy(source, keySelector, comparer); +#endif } #pragma warning restore 1591 @@ -773,7 +897,11 @@ public static IQueryable OnErrorResumeNext(this IQueryable OnErrorResumeNext(IEnumerable> sources) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.OnErrorResumeNext(sources); +#endif } #pragma warning restore 1591 @@ -797,7 +925,11 @@ public static IQueryable OnErrorResumeNext(this IQueryable OnErrorResumeNext(IEnumerable first, IEnumerable second) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.OnErrorResumeNext(first, second); +#endif } #pragma warning restore 1591 @@ -821,7 +953,11 @@ public static IQueryable Publish(this IQueryable Publish(IEnumerable source, Func, IEnumerable> selector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Publish(source, selector); +#endif } #pragma warning restore 1591 @@ -843,7 +979,11 @@ public static IQueryable Repeat(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Repeat(IEnumerable source) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Repeat(source); +#endif } #pragma warning restore 1591 @@ -865,7 +1005,11 @@ public static IQueryable Repeat(this IQueryable sourc [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Repeat(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Repeat(source, count); +#endif } #pragma warning restore 1591 @@ -887,7 +1031,11 @@ public static IQueryable Retry(this IQueryable source [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Retry(IEnumerable source) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Retry(source); +#endif } #pragma warning restore 1591 @@ -909,7 +1057,11 @@ public static IQueryable Retry(this IQueryable source [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Retry(IEnumerable source, int retryCount) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Retry(source, retryCount); +#endif } #pragma warning restore 1591 @@ -933,7 +1085,11 @@ public static IQueryable Scan(this IQueryable source, [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Scan(IEnumerable source, Func accumulator) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Scan(source, accumulator); +#endif } #pragma warning restore 1591 @@ -957,7 +1113,11 @@ public static IQueryable Scan(this IQueryable [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable Scan(IEnumerable source, TAccumulate seed, Func accumulator) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Scan(source, seed, accumulator); +#endif } #pragma warning restore 1591 @@ -981,7 +1141,11 @@ public static IQueryable SelectMany(this IQueryable SelectMany(IEnumerable source, IEnumerable other) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.SelectMany(source, other); +#endif } #pragma warning restore 1591 @@ -1005,7 +1169,11 @@ public static IQueryable Share(this IQueryable Share(IEnumerable source, Func, IEnumerable> selector) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.Share(source, selector); +#endif } #pragma warning restore 1591 @@ -1027,7 +1195,11 @@ public static IQueryable SkipLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable SkipLast(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.SkipLast(source, count); +#endif } #pragma warning restore 1591 @@ -1051,7 +1223,11 @@ public static IQueryable StartWith(this IQueryable so [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable StartWith(IEnumerable source, TSource[] values) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.StartWith(source, values); +#endif } #pragma warning restore 1591 @@ -1073,7 +1249,11 @@ public static IQueryable TakeLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable TakeLast(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return default; +#else return EnumerableEx.TakeLast(source, count); +#endif } #pragma warning restore 1591