Skip to content

Commit a4a2288

Browse files
committed
update return types and tests
1 parent cb03c99 commit a4a2288

File tree

5 files changed

+314
-66
lines changed

5 files changed

+314
-66
lines changed

src/MongoDB.Driver/Linq/ISetWindowFieldsPartitionExtensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ public static TValue Max<TInput, TValue>(this ISetWindowFieldsPartition<TInput>
886886
/// <param name="selector">The selector that selects a value from the input document.</param>
887887
/// <param name="window">The window boundaries.</param>
888888
/// <returns>The median of the selected values.</returns>
889-
public static double Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal> selector, SetWindowFieldsWindow window = null)
889+
public static decimal Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal> selector, SetWindowFieldsWindow window = null)
890890
{
891891
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
892892
}
@@ -899,7 +899,7 @@ public static double Median<TInput>(this ISetWindowFieldsPartition<TInput> parti
899899
/// <param name="selector">The selector that selects a value from the input document.</param>
900900
/// <param name="window">The window boundaries.</param>
901901
/// <returns>The median of the selected values.</returns>
902-
public static double? Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal?> selector, SetWindowFieldsWindow window = null)
902+
public static decimal? Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal?> selector, SetWindowFieldsWindow window = null)
903903
{
904904
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
905905
}
@@ -938,7 +938,7 @@ public static double Median<TInput>(this ISetWindowFieldsPartition<TInput> parti
938938
/// <param name="selector">The selector that selects a value from the input document.</param>
939939
/// <param name="window">The window boundaries.</param>
940940
/// <returns>The median of the selected values.</returns>
941-
public static double Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float> selector, SetWindowFieldsWindow window = null)
941+
public static float Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float> selector, SetWindowFieldsWindow window = null)
942942
{
943943
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
944944
}
@@ -951,7 +951,7 @@ public static double Median<TInput>(this ISetWindowFieldsPartition<TInput> parti
951951
/// <param name="selector">The selector that selects a value from the input document.</param>
952952
/// <param name="window">The window boundaries.</param>
953953
/// <returns>The median of the selected values.</returns>
954-
public static double? Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float?> selector, SetWindowFieldsWindow window = null)
954+
public static float? Median<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float?> selector, SetWindowFieldsWindow window = null)
955955
{
956956
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
957957
}
@@ -1031,7 +1031,7 @@ public static TValue Min<TInput, TValue>(this ISetWindowFieldsPartition<TInput>
10311031
/// <param name="percentiles">The percentiles (between 0.0 and 1.0).</param>
10321032
/// <param name="window">The window boundaries.</param>
10331033
/// <returns>The values at the given percentiles.</returns>
1034-
public static double[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
1034+
public static decimal[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
10351035
{
10361036
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
10371037
}
@@ -1045,7 +1045,7 @@ public static double[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput>
10451045
/// <param name="percentiles">The percentiles (between 0.0 and 1.0).</param>
10461046
/// <param name="window">The window boundaries.</param>
10471047
/// <returns>The values at the given percentiles.</returns>
1048-
public static double?[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal?> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
1048+
public static decimal?[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, decimal?> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
10491049
{
10501050
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
10511051
}
@@ -1087,7 +1087,7 @@ public static double[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput>
10871087
/// <param name="percentiles">The percentiles (between 0.0 and 1.0).</param>
10881088
/// <param name="window">The window boundaries.</param>
10891089
/// <returns>The values at the given percentiles.</returns>
1090-
public static double[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
1090+
public static float[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
10911091
{
10921092
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
10931093
}
@@ -1101,7 +1101,7 @@ public static double[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput>
11011101
/// <param name="percentiles">The percentiles (between 0.0 and 1.0).</param>
11021102
/// <param name="window">The window boundaries.</param>
11031103
/// <returns>The values at the given percentiles.</returns>
1104-
public static double?[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float?> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
1104+
public static float?[] Percentile<TInput>(this ISetWindowFieldsPartition<TInput> partition, Func<TInput, float?> selector, IEnumerable<double> percentiles, SetWindowFieldsWindow window = null)
11051105
{
11061106
throw new InvalidOperationException("This method is only intended to be used with SetWindowFields.");
11071107
}

src/MongoDB.Driver/Linq/MongoEnumerable.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public static IEnumerable<TResult> MaxN<TSource, TKey, TResult>(
241241
/// </summary>
242242
/// <param name="source">The sequence of values.</param>
243243
/// <returns>The median value.</returns>
244-
public static double Median(this IEnumerable<decimal> source)
244+
public static decimal Median(this IEnumerable<decimal> source)
245245
{
246246
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
247247
}
@@ -251,7 +251,7 @@ public static double Median(this IEnumerable<decimal> source)
251251
/// </summary>
252252
/// <param name="source">The sequence of values.</param>
253253
/// <returns>The median value.</returns>
254-
public static double? Median(this IEnumerable<decimal?> source)
254+
public static decimal? Median(this IEnumerable<decimal?> source)
255255
{
256256
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
257257
}
@@ -281,7 +281,7 @@ public static double Median(this IEnumerable<double> source)
281281
/// </summary>
282282
/// <param name="source">The sequence of values.</param>
283283
/// <returns>The median value.</returns>
284-
public static double Median(this IEnumerable<float> source)
284+
public static float Median(this IEnumerable<float> source)
285285
{
286286
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
287287
}
@@ -291,7 +291,7 @@ public static double Median(this IEnumerable<float> source)
291291
/// </summary>
292292
/// <param name="source">The sequence of values.</param>
293293
/// <returns>The median value.</returns>
294-
public static double? Median(this IEnumerable<float?> source)
294+
public static float? Median(this IEnumerable<float?> source)
295295
{
296296
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
297297
}
@@ -343,7 +343,7 @@ public static double Median(this IEnumerable<long> source)
343343
/// <param name="source">A sequence of values to calculate the median of.</param>
344344
/// <param name="selector">A transform function to apply to each element.</param>
345345
/// <returns>The median value.</returns>
346-
public static double Median<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
346+
public static decimal Median<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
347347
{
348348
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
349349
}
@@ -355,7 +355,7 @@ public static double Median<TSource>(this IEnumerable<TSource> source, Func<TSou
355355
/// <param name="source">A sequence of values to calculate the median of.</param>
356356
/// <param name="selector">A transform function to apply to each element.</param>
357357
/// <returns>The median value.</returns>
358-
public static double? Median<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
358+
public static decimal? Median<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
359359
{
360360
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
361361
}
@@ -391,7 +391,7 @@ public static double Median<TSource>(this IEnumerable<TSource> source, Func<TSou
391391
/// <param name="source">A sequence of values to calculate the median of.</param>
392392
/// <param name="selector">A transform function to apply to each element.</param>
393393
/// <returns>The median value.</returns>
394-
public static double Median<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
394+
public static float Median<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
395395
{
396396
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
397397
}
@@ -403,7 +403,7 @@ public static double Median<TSource>(this IEnumerable<TSource> source, Func<TSou
403403
/// <param name="source">A sequence of values to calculate the median of.</param>
404404
/// <param name="selector">A transform function to apply to each element.</param>
405405
/// <returns>The median value.</returns>
406-
public static double? Median<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
406+
public static float? Median<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
407407
{
408408
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
409409
}
@@ -499,7 +499,7 @@ public static IEnumerable<TResult> MinN<TSource, TKey, TResult>(
499499
/// <param name="source">A sequence of values to calculate the percentiles of.</param>
500500
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
501501
/// <returns>The percentiles of the sequence of values.</returns>
502-
public static double[] Percentile(this IEnumerable<decimal> source, IEnumerable<double> percentiles)
502+
public static decimal[] Percentile(this IEnumerable<decimal> source, IEnumerable<double> percentiles)
503503
{
504504
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
505505
}
@@ -510,7 +510,7 @@ public static double[] Percentile(this IEnumerable<decimal> source, IEnumerable<
510510
/// <param name="source">A sequence of values to calculate the percentiles of.</param>
511511
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
512512
/// <returns>The percentiles of the sequence of values.</returns>
513-
public static double?[] Percentile(this IEnumerable<decimal?> source, IEnumerable<double> percentiles)
513+
public static decimal?[] Percentile(this IEnumerable<decimal?> source, IEnumerable<double> percentiles)
514514
{
515515
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
516516
}
@@ -543,7 +543,7 @@ public static double[] Percentile(this IEnumerable<double> source, IEnumerable<d
543543
/// <param name="source">A sequence of values to calculate the percentiles of.</param>
544544
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
545545
/// <returns>The percentiles of the sequence of values.</returns>
546-
public static double[] Percentile(this IEnumerable<float> source, IEnumerable<double> percentiles)
546+
public static float[] Percentile(this IEnumerable<float> source, IEnumerable<double> percentiles)
547547
{
548548
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
549549
}
@@ -554,7 +554,7 @@ public static double[] Percentile(this IEnumerable<float> source, IEnumerable<do
554554
/// <param name="source">A sequence of values to calculate the percentiles of.</param>
555555
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
556556
/// <returns>The percentiles of the sequence of values.</returns>
557-
public static double?[] Percentile(this IEnumerable<float?> source, IEnumerable<double> percentiles)
557+
public static float?[] Percentile(this IEnumerable<float?> source, IEnumerable<double> percentiles)
558558
{
559559
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
560560
}
@@ -611,7 +611,7 @@ public static double[] Percentile(this IEnumerable<long> source, IEnumerable<dou
611611
/// <param name="selector">A transform function to apply to each element.</param>
612612
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
613613
/// <returns>The percentiles of the sequence of values.</returns>
614-
public static double[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector, IEnumerable<double> percentiles)
614+
public static decimal[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector, IEnumerable<double> percentiles)
615615
{
616616
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
617617
}
@@ -624,7 +624,7 @@ public static double[] Percentile<TSource>(this IEnumerable<TSource> source, Fun
624624
/// <param name="selector">A transform function to apply to each element.</param>
625625
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
626626
/// <returns>The percentiles of the sequence of values.</returns>
627-
public static double?[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector, IEnumerable<double> percentiles)
627+
public static decimal?[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector, IEnumerable<double> percentiles)
628628
{
629629
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
630630
}
@@ -663,7 +663,7 @@ public static double[] Percentile<TSource>(this IEnumerable<TSource> source, Fun
663663
/// <param name="selector">A transform function to apply to each element.</param>
664664
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
665665
/// <returns>The percentiles of the sequence of values.</returns>
666-
public static double[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector, IEnumerable<double> percentiles)
666+
public static float[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector, IEnumerable<double> percentiles)
667667
{
668668
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
669669
}
@@ -676,7 +676,7 @@ public static double[] Percentile<TSource>(this IEnumerable<TSource> source, Fun
676676
/// <param name="selector">A transform function to apply to each element.</param>
677677
/// <param name="percentiles">The percentiles to compute (each between 0.0 and 1.0).</param>
678678
/// <returns>The percentiles of the sequence of values.</returns>
679-
public static double?[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector, IEnumerable<double> percentiles)
679+
public static float?[] Percentile<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector, IEnumerable<double> percentiles)
680680
{
681681
throw CustomLinqExtensionMethodHelper.CreateNotSupportedException();
682682
}

0 commit comments

Comments
 (0)