Skip to content

Commit

Permalink
Use "Delegate.Comparer", retiring "Comparer"
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Jan 15, 2023
1 parent 34c7ebe commit ab2e13a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 49 deletions.
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
Expand Up @@ -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" />
Expand Down
3 changes: 2 additions & 1 deletion MoreLinq.Test/OrderByTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions MoreLinq.Test/RankTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace MoreLinq.Test
{
using System;
using NUnit.Framework;
using Delegate = Delegating.Delegate;

/// <summary>
/// Verify the behavior of the Rank operator
Expand Down Expand Up @@ -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()));
Expand Down

0 comments on commit ab2e13a

Please sign in to comment.