|
@@ -1,163 +0,0 @@
|
|
|
-// Licensed to the .NET Foundation under one or more agreements.
|
|
|
-// The .NET Foundation licenses this file to you under the MIT License.
|
|
|
-// See the LICENSE file in the project root for more information.
|
|
|
-
|
|
|
-<#@ template debug="false" hostspecific="false" language="C#" #>
|
|
|
-<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #>
|
|
|
-<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #>
|
|
|
-<#@ assembly name="System.Core" #>
|
|
|
-<#@ assembly name="System.Runtime" #>
|
|
|
-<#@ import namespace="System.Collections.Generic" #>
|
|
|
-<#@ import namespace="System.Linq" #>
|
|
|
-<#@ import namespace="System.Reflection" #>
|
|
|
-<#@ output extension=".cs" #>
|
|
|
-<#
|
|
|
-Func<Type, string> toCSharp = null;
|
|
|
-toCSharp = t =>
|
|
|
-{
|
|
|
- if (t.IsGenericType)
|
|
|
- {
|
|
|
- var def = t.GetGenericTypeDefinition();
|
|
|
- if (def == typeof(Nullable<>))
|
|
|
- {
|
|
|
- return toCSharp(t.GetGenericArguments()[0]) + "?";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return def.Name.Substring(0, def.Name.IndexOf('`')) + "<" + string.Join(", ", t.GetGenericArguments().Select(toCSharp)) + ">";
|
|
|
- }
|
|
|
- }
|
|
|
- else if (t.IsArray)
|
|
|
- {
|
|
|
- return toCSharp(t.GetElementType()) + "[]";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (t == typeof(int))
|
|
|
- {
|
|
|
- return "int";
|
|
|
- }
|
|
|
- else if (t == typeof(long))
|
|
|
- {
|
|
|
- return "long";
|
|
|
- }
|
|
|
- else if (t == typeof(float))
|
|
|
- {
|
|
|
- return "float";
|
|
|
- }
|
|
|
- else if (t == typeof(double))
|
|
|
- {
|
|
|
- return "double";
|
|
|
- }
|
|
|
- else if (t == typeof(decimal))
|
|
|
- {
|
|
|
- return "decimal";
|
|
|
- }
|
|
|
- else if (t == typeof(bool))
|
|
|
- {
|
|
|
- return "bool";
|
|
|
- }
|
|
|
- else if (t == typeof(object))
|
|
|
- {
|
|
|
- return "object";
|
|
|
- }
|
|
|
-
|
|
|
- return t.Name;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-Func<ParameterInfo, string> getOptionalSuffix = p =>
|
|
|
-{
|
|
|
- if (p.IsOptional)
|
|
|
- {
|
|
|
- return " = default";
|
|
|
- }
|
|
|
-
|
|
|
- return "";
|
|
|
-};
|
|
|
-#>
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Threading;
|
|
|
-using System.Threading.Tasks;
|
|
|
-
|
|
|
-namespace System.Linq
|
|
|
-{
|
|
|
- partial class AsyncEnumerable
|
|
|
- {
|
|
|
-<#
|
|
|
-var methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.NonPublic | BindingFlags.Static);
|
|
|
-var asyncMethods = methods.Where(m => m.Name.Contains("Await") && m.Name.EndsWith("Core")).OrderBy(m => m.Name).ThenBy(m => m.GetParameters().Length);
|
|
|
-#>
|
|
|
-#if SUPPORT_FLAT_ASYNC_API
|
|
|
-<#
|
|
|
-foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation")))
|
|
|
-{
|
|
|
- if (g.Key)
|
|
|
- {
|
|
|
-#>
|
|
|
-
|
|
|
-#if !NO_DEEP_CANCELLATION
|
|
|
-<#
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var m in g)
|
|
|
- {
|
|
|
- var longName = m.Name;
|
|
|
- var shortName = m.Name.Replace("WithCancellation", "").Replace("Await", "").Replace("Core", "");
|
|
|
- var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : "";
|
|
|
- var returnType = toCSharp(m.ReturnType);
|
|
|
- var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true);
|
|
|
- var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name + getOptionalSuffix(p)));
|
|
|
- var args = string.Join(", ", m.GetParameters().Select(p => p.Name));
|
|
|
- var cons = m.Name.StartsWith("ToDictionary") ? " where TKey : notnull" : "";
|
|
|
-#>
|
|
|
- public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>)<#=cons#> => <#=longName#><#=genArgs#>(<#=args#>);
|
|
|
-<#
|
|
|
- }
|
|
|
-
|
|
|
- if (g.Key)
|
|
|
- {
|
|
|
-#>
|
|
|
-#endif
|
|
|
-<#
|
|
|
- }
|
|
|
-}
|
|
|
-#>
|
|
|
-#else
|
|
|
-<#
|
|
|
-foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation")))
|
|
|
-{
|
|
|
- if (g.Key)
|
|
|
- {
|
|
|
-#>
|
|
|
-
|
|
|
-#if !NO_DEEP_CANCELLATION
|
|
|
-<#
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var m in g)
|
|
|
- {
|
|
|
- var longName = m.Name;
|
|
|
- var shortName = m.Name.Replace("Core", "");
|
|
|
- var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : "";
|
|
|
- var returnType = toCSharp(m.ReturnType);
|
|
|
- var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true);
|
|
|
- var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name + getOptionalSuffix(p)));
|
|
|
- var args = string.Join(", ", m.GetParameters().Select(p => p.Name));
|
|
|
- var cons = m.Name.StartsWith("ToDictionary") ? " where TKey : notnull" : "";
|
|
|
-#>
|
|
|
- public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>)<#=cons#> => <#=longName#><#=genArgs#>(<#=args#>);
|
|
|
-<#
|
|
|
- }
|
|
|
-
|
|
|
- if (g.Key)
|
|
|
- {
|
|
|
-#>
|
|
|
-#endif
|
|
|
-<#
|
|
|
- }
|
|
|
-}
|
|
|
-#>
|
|
|
-#endif
|
|
|
- }
|
|
|
-}
|