From fc3ee2f37051f4be79f5a9baa06d9bb3cf4a265b Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 9 Nov 2022 07:53:33 +0100 Subject: [PATCH] Replace "MayBeNull" with "?" in "IExtremaEnumerable<>" members (#872) This is a squashed merge of PR #872 that adds to #803. --- MoreLinq.Test/MaxByTest.cs | 2 ++ MoreLinq.Test/MinByTest.cs | 2 ++ MoreLinq/Extensions.g.cs | 9 +++------ MoreLinq/MaxBy.cs | 10 +++------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/MoreLinq.Test/MaxByTest.cs b/MoreLinq.Test/MaxByTest.cs index 737d10e93..6480e932e 100644 --- a/MoreLinq.Test/MaxByTest.cs +++ b/MoreLinq.Test/MaxByTest.cs @@ -15,6 +15,8 @@ // limitations under the License. #endregion +#nullable enable + namespace MoreLinq.Test { using System; diff --git a/MoreLinq.Test/MinByTest.cs b/MoreLinq.Test/MinByTest.cs index 934e49dd5..79d2da26e 100644 --- a/MoreLinq.Test/MinByTest.cs +++ b/MoreLinq.Test/MinByTest.cs @@ -15,6 +15,8 @@ // limitations under the License. #endregion +#nullable enable + namespace MoreLinq.Test { using System; diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index bead709d2..1a77a18e6 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1907,8 +1907,7 @@ public static partial class FirstOrDefaultExtension /// otherwise, the first element in source. /// - [return: MaybeNull] - public static T FirstOrDefault(this IExtremaEnumerable source) + public static T? FirstOrDefault(this IExtremaEnumerable source) => MoreEnumerable.FirstOrDefault(source); } @@ -3114,8 +3113,7 @@ public static partial class LastOrDefaultExtension /// otherwise, the last element in source. /// - [return: MaybeNull] - public static T LastOrDefault(this IExtremaEnumerable source) + public static T? LastOrDefault(this IExtremaEnumerable source) => MoreEnumerable.LastOrDefault(source); } @@ -5178,8 +5176,7 @@ public static partial class SingleOrDefaultExtension /// if the sequence contains no elements. /// - [return: MaybeNull] - public static T SingleOrDefault(this IExtremaEnumerable source) + public static T? SingleOrDefault(this IExtremaEnumerable source) => MoreEnumerable.SingleOrDefault(source); } diff --git a/MoreLinq/MaxBy.cs b/MoreLinq/MaxBy.cs index 3752c1645..b9dbb1ac6 100644 --- a/MoreLinq/MaxBy.cs +++ b/MoreLinq/MaxBy.cs @@ -20,7 +20,6 @@ namespace MoreLinq using System; using System.Collections; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using System.Linq; /// @@ -88,8 +87,7 @@ public static T First(this IExtremaEnumerable source) /// otherwise, the first element in source. /// - [return: MaybeNull] - public static T FirstOrDefault(this IExtremaEnumerable source) + public static T? FirstOrDefault(this IExtremaEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Take(1).AsEnumerable().FirstOrDefault(); @@ -125,8 +123,7 @@ public static T Last(this IExtremaEnumerable source) /// otherwise, the last element in source. /// - [return: MaybeNull] - public static T LastOrDefault(this IExtremaEnumerable source) + public static T? LastOrDefault(this IExtremaEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.TakeLast(1).AsEnumerable().LastOrDefault(); @@ -164,8 +161,7 @@ public static T Single(this IExtremaEnumerable source) /// if the sequence contains no elements. /// - [return: MaybeNull] - public static T SingleOrDefault(this IExtremaEnumerable source) + public static T? SingleOrDefault(this IExtremaEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return source.Take(2).AsEnumerable().SingleOrDefault();