Pārlūkot izejas kodu

Use T4 to generate Zip and CombineLatest code.

Bart De Smet 5 gadi atpakaļ
vecāks
revīzija
6ec0ab8385

+ 2 - 2
Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.Generated.cs

@@ -6,9 +6,9 @@ namespace System.Reactive.Linq
 {
     public static partial class Observable
     {
-        /* The following code is generated by a tool checked in to $/.../Source/Tools/CodeGenerators. */
+        /* The following code is generated by a T4 template. */
 
-        #region CombineLatest auto-generated code (8/3/2012 6:37:08 PM)
+        #region CombineLatest auto-generated code (09/25/2020 12:10:41)
 
         /// <summary>
         /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

+ 83 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.tt

@@ -0,0 +1,83 @@
+// 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="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ output extension=".Generated.cs" #>
+namespace System.Reactive.Linq
+{
+    public static partial class Observable
+    {
+        /* The following code is generated by a T4 template. */
+
+        #region CombineLatest auto-generated code (<#=DateTime.Now#>)
+
+<#
+Func<string, string> toUpper = s => char.ToUpper(s[0]) + s.Substring(1);
+
+string[] ordinals = new[] { "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth" };
+
+for (int i = 3; i <= 16; i++)
+{
+    var parameters = string.Join(", ", Enumerable.Range(1, i).Select(j => "IObservable<TSource" + j + "> source" + j));
+    var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j));
+    var sources = string.Join(", ", Enumerable.Range(1, i).Select(j => "source" + j));
+    var paramRefs = string.Join(" or ", Enumerable.Range(1, i).Select(j => "<paramref name=\"source" + j + "\"/>"));
+
+#>
+        /// <summary>
+        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
+        /// </summary>
+<#
+for (int j = 0; j < i; j++)
+{
+#>
+        /// <typeparam name="TSource<#=j + 1#>">The type of the elements in the <#=ordinals[j]#> source sequence.</typeparam>
+<#
+}
+#>
+        /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
+<#
+for (int j = 0; j < i; j++)
+{
+#>
+        /// <param name="source<#=j + 1#>"><#=toUpper(ordinals[j])#> observable source.</param>
+<#
+}
+#>
+        /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
+        /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
+        /// <exception cref="ArgumentNullException"><#=paramRefs#> or <paramref name="resultSelector"/> is null.</exception>
+        /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
+        public static IObservable<TResult> CombineLatest<<#=genArgs#>, TResult>(this <#=parameters#>, Func<<#=genArgs#>, TResult> resultSelector)
+        {
+<#
+for (int j = 0; j < i; j++)
+{
+#>
+            if (source<#=j + 1#> == null)
+            {
+                throw new ArgumentNullException(nameof(source<#=j + 1#>));
+            }
+
+<#
+}
+#>
+            if (resultSelector == null)
+            {
+                throw new ArgumentNullException(nameof(resultSelector));
+            }
+
+            return s_impl.CombineLatest(<#=sources#>, resultSelector);
+        }
+
+<#
+}
+#>
+        #endregion
+    }
+}

+ 2 - 2
Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.Generated.cs

@@ -6,9 +6,9 @@ namespace System.Reactive.Linq
 {
     public static partial class Observable
     {
-        /* The following code is generated by a tool checked in to $/.../Source/Tools/CodeGenerators. */
+        /* The following code is generated by a T4 template. */
 
-        #region Zip auto-generated code (8/3/2012 6:37:02 PM)
+        #region Zip auto-generated code (09/25/2020 12:10:41)
 
         /// <summary>
         /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.

+ 82 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.tt

@@ -0,0 +1,82 @@
+// 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="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ output extension=".Generated.cs" #>
+namespace System.Reactive.Linq
+{
+    public static partial class Observable
+    {
+        /* The following code is generated by a T4 template. */
+
+        #region Zip auto-generated code (<#=DateTime.Now#>)
+
+<#
+Func<string, string> toUpper = s => char.ToUpper(s[0]) + s.Substring(1);
+
+string[] ordinals = new[] { "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth" };
+
+for (int i = 3; i <= 16; i++)
+{
+    var parameters = string.Join(", ", Enumerable.Range(1, i).Select(j => "IObservable<TSource" + j + "> source" + j));
+    var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j));
+    var sources = string.Join(", ", Enumerable.Range(1, i).Select(j => "source" + j));
+    var paramRefs = string.Join(" or ", Enumerable.Range(1, i).Select(j => "<paramref name=\"source" + j + "\"/>"));
+
+#>
+        /// <summary>
+        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
+        /// </summary>
+<#
+for (int j = 0; j < i; j++)
+{
+#>
+        /// <typeparam name="TSource<#=j + 1#>">The type of the elements in the <#=ordinals[j]#> source sequence.</typeparam>
+<#
+}
+#>
+        /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
+<#
+for (int j = 0; j < i; j++)
+{
+#>
+        /// <param name="source<#=j + 1#>"><#=toUpper(ordinals[j])#> observable source.</param>
+<#
+}
+#>
+        /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
+        /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
+        /// <exception cref="ArgumentNullException"><#=paramRefs#> or <paramref name="resultSelector"/> is null.</exception>
+        public static IObservable<TResult> Zip<<#=genArgs#>, TResult>(this <#=parameters#>, Func<<#=genArgs#>, TResult> resultSelector)
+        {
+<#
+for (int j = 0; j < i; j++)
+{
+#>
+            if (source<#=j + 1#> == null)
+            {
+                throw new ArgumentNullException(nameof(source<#=j + 1#>));
+            }
+
+<#
+}
+#>
+            if (resultSelector == null)
+            {
+                throw new ArgumentNullException(nameof(resultSelector));
+            }
+
+            return s_impl.Zip(<#=sources#>, resultSelector);
+        }
+
+<#
+}
+#>
+        #endregion
+    }
+}

+ 3 - 3
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Multiple.CombineLatest.Generated.cs

@@ -1,6 +1,6 @@
 // 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. 
+// See the LICENSE file in the project root for more information.
 
 namespace System.Reactive.Linq
 {
@@ -8,9 +8,9 @@ namespace System.Reactive.Linq
 
     internal partial class QueryLanguage
     {
-        /* The following code is generated by a tool checked in to $/.../Source/Tools/CodeGenerators. */
+        /* The following code is generated by a T4 template. */
 
-        #region CombineLatest auto-generated code (6/10/2012 7:25:03 PM)
+        #region CombineLatest auto-generated code (09/25/2020 12:31:33)
 
         public virtual IObservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TResult>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, Func<TSource1, TSource2, TSource3, TResult> resultSelector)
         {

+ 39 - 0
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Multiple.CombineLatest.tt

@@ -0,0 +1,39 @@
+// 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="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ output extension=".Generated.cs" #>
+namespace System.Reactive.Linq
+{
+    using ObservableImpl;
+
+    internal partial class QueryLanguage
+    {
+        /* The following code is generated by a T4 template. */
+
+        #region CombineLatest auto-generated code (<#=DateTime.Now#>)
+
+<#
+for (int i = 3; i <= 16; i++)
+{
+    var parameters = string.Join(", ", Enumerable.Range(1, i).Select(j => "IObservable<TSource" + j + "> source" + j));
+    var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j));
+    var sources = string.Join(", ", Enumerable.Range(1, i).Select(j => "source" + j));
+
+#>
+        public virtual IObservable<TResult> CombineLatest<<#=genArgs#>, TResult>(<#=parameters#>, Func<<#=genArgs#>, TResult> resultSelector)
+        {
+            return new CombineLatest<<#=genArgs#>, TResult>(<#=sources#>, resultSelector);
+        }
+
+<#
+}
+#>
+        #endregion
+    }
+}

+ 3 - 3
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Multiple.Zip.Generated.cs

@@ -1,6 +1,6 @@
 // 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. 
+// See the LICENSE file in the project root for more information.
 
 namespace System.Reactive.Linq
 {
@@ -8,9 +8,9 @@ namespace System.Reactive.Linq
 
     internal partial class QueryLanguage
     {
-        /* The following code is generated by a tool checked in to $/.../Source/Tools/CodeGenerators. */
+        /* The following code is generated by a T4 template. */
 
-        #region Zip auto-generated code (6/10/2012 8:15:28 PM)
+        #region Zip auto-generated code (09/25/2020 12:21:27)
 
         public virtual IObservable<TResult> Zip<TSource1, TSource2, TSource3, TResult>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, Func<TSource1, TSource2, TSource3, TResult> resultSelector)
         {

+ 39 - 0
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Multiple.Zip.tt

@@ -0,0 +1,39 @@
+// 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="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ output extension=".Generated.cs" #>
+namespace System.Reactive.Linq
+{
+    using ObservableImpl;
+
+    internal partial class QueryLanguage
+    {
+        /* The following code is generated by a T4 template. */
+
+        #region Zip auto-generated code (<#=DateTime.Now#>)
+
+<#
+for (int i = 3; i <= 16; i++)
+{
+    var parameters = string.Join(", ", Enumerable.Range(1, i).Select(j => "IObservable<TSource" + j + "> source" + j));
+    var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j));
+    var sources = string.Join(", ", Enumerable.Range(1, i).Select(j => "source" + j));
+
+#>
+        public virtual IObservable<TResult> Zip<<#=genArgs#>, TResult>(<#=parameters#>, Func<<#=genArgs#>, TResult> resultSelector)
+        {
+            return new Zip<<#=genArgs#>, TResult>(<#=sources#>, resultSelector);
+        }
+
+<#
+}
+#>
+        #endregion
+    }
+}