Skip to content

Commit

Permalink
Replace "MayBeNull" with "?" in "IExtremaEnumerable<>" members (#872)
Browse files Browse the repository at this point in the history
This is a squashed merge of PR #872 that adds to #803.
  • Loading branch information
atifaziz authored Nov 9, 2022
1 parent 947ad71 commit fc3ee2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 2 additions & 0 deletions MoreLinq.Test/MaxByTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#nullable enable

namespace MoreLinq.Test
{
using System;
Expand Down
2 changes: 2 additions & 0 deletions MoreLinq.Test/MinByTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#nullable enable

namespace MoreLinq.Test
{
using System;
Expand Down
9 changes: 3 additions & 6 deletions MoreLinq/Extensions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1907,8 +1907,7 @@ public static partial class FirstOrDefaultExtension
/// otherwise, the first element in source.
/// </returns>

[return: MaybeNull]
public static T FirstOrDefault<T>(this IExtremaEnumerable<T> source)
public static T? FirstOrDefault<T>(this IExtremaEnumerable<T> source)
=> MoreEnumerable.FirstOrDefault(source);

}
Expand Down Expand Up @@ -3114,8 +3113,7 @@ public static partial class LastOrDefaultExtension
/// otherwise, the last element in source.
/// </returns>

[return: MaybeNull]
public static T LastOrDefault<T>(this IExtremaEnumerable<T> source)
public static T? LastOrDefault<T>(this IExtremaEnumerable<T> source)
=> MoreEnumerable.LastOrDefault(source);

}
Expand Down Expand Up @@ -5178,8 +5176,7 @@ public static partial class SingleOrDefaultExtension
/// <typeparamref name="T"/> if the sequence contains no elements.
/// </returns>

[return: MaybeNull]
public static T SingleOrDefault<T>(this IExtremaEnumerable<T> source)
public static T? SingleOrDefault<T>(this IExtremaEnumerable<T> source)
=> MoreEnumerable.SingleOrDefault(source);

}
Expand Down
10 changes: 3 additions & 7 deletions MoreLinq/MaxBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace MoreLinq
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

/// <summary>
Expand Down Expand Up @@ -88,8 +87,7 @@ public static T First<T>(this IExtremaEnumerable<T> source)
/// otherwise, the first element in source.
/// </returns>

[return: MaybeNull]
public static T FirstOrDefault<T>(this IExtremaEnumerable<T> source)
public static T? FirstOrDefault<T>(this IExtremaEnumerable<T> source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
return source.Take(1).AsEnumerable().FirstOrDefault();
Expand Down Expand Up @@ -125,8 +123,7 @@ public static T Last<T>(this IExtremaEnumerable<T> source)
/// otherwise, the last element in source.
/// </returns>

[return: MaybeNull]
public static T LastOrDefault<T>(this IExtremaEnumerable<T> source)
public static T? LastOrDefault<T>(this IExtremaEnumerable<T> source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
return source.TakeLast(1).AsEnumerable().LastOrDefault();
Expand Down Expand Up @@ -164,8 +161,7 @@ public static T Single<T>(this IExtremaEnumerable<T> source)
/// <typeparamref name="T"/> if the sequence contains no elements.
/// </returns>

[return: MaybeNull]
public static T SingleOrDefault<T>(this IExtremaEnumerable<T> source)
public static T? SingleOrDefault<T>(this IExtremaEnumerable<T> source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
return source.Take(2).AsEnumerable().SingleOrDefault();
Expand Down

0 comments on commit fc3ee2f

Please sign in to comment.