Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retire our delegating Comparer #921

Merged
merged 3 commits into from
Jan 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions MoreLinq.Test/Comparer.cs

This file was deleted.

1 change: 0 additions & 1 deletion MoreLinq.Test/MoreLinq.Test.csproj
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@
<Compile Include="BreakingSequence.cs" />
<Compile Include="Combinatorics.cs" />
<Compile Include="Comparable.cs" />
<Compile Include="Comparer.cs" />
<Compile Include="CurrentThreadCultureScope.cs" />
<Compile Include="Enumerable.cs" />
<Compile Include="EqualityComparer.cs" />
3 changes: 2 additions & 1 deletion MoreLinq.Test/OrderByTest.cs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ namespace MoreLinq.Test
{
using System.Collections.Generic;
using NUnit.Framework;
using Delegate = Delegating.Delegate;

/// <summary>
/// Verify the behavior of the OrderBy/ThenBy operators
@@ -47,7 +48,7 @@ public void TestOrderBySelectorPreserved()
}

static readonly IComparer<string> NumericStringComparer =
Comparer.Create((string? a, string? b) =>
Delegate.Comparer((string? a, string? b) =>
(a, b) switch
{
(null, null) => 0,
5 changes: 3 additions & 2 deletions MoreLinq.Test/RankTest.cs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ namespace MoreLinq.Test
{
using System;
using NUnit.Framework;
using Delegate = Delegating.Delegate;

/// <summary>
/// Verify the behavior of the Rank operator
@@ -172,8 +173,8 @@ public void TestRankCustomComparer()
var ordinals = Enumerable.Range(1, count);
var sequence = ordinals.Select( x => new DateTime(2010,x,20-x) );
// invert the CompareTo operation to Rank in reverse order (ascending to descending)
var resultA = sequence.AsTestingSequence().Rank(Comparer.Create<DateTime>((a, b) => -a.CompareTo(b)));
var resultB = sequence.AsTestingSequence().RankBy(x => x.Day, Comparer.Create<int>((a, b) => -a.CompareTo(b)));
var resultA = sequence.AsTestingSequence().Rank(Delegate.Comparer<DateTime>((a, b) => -a.CompareTo(b)));
var resultB = sequence.AsTestingSequence().RankBy(x => x.Day, Delegate.Comparer<int>((a, b) => -a.CompareTo(b)));

Assert.That(resultA, Is.EqualTo(ordinals));
Assert.That(resultB, Is.EqualTo(ordinals.Reverse()));