Skip to content

Commit f75273c

Browse files
Copilotbaywet
andcommitted
Remove unused Sort extension methods from CollectionExtensions
Co-authored-by: baywet <[email protected]>
1 parent f0469c5 commit f75273c

File tree

1 file changed

+1
-42
lines changed

1 file changed

+1
-42
lines changed
Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
5-
namespace Microsoft.OpenApi
1+
namespace Microsoft.OpenApi
62
{
73
/// <summary>
84
/// Dictionary extension methods
95
/// </summary>
106
internal static class CollectionExtensions
117
{
12-
/// <summary>
13-
/// Returns a new dictionary with entries sorted by key using a custom comparer.
14-
/// </summary>
15-
internal static IDictionary<TKey, TValue> Sort<TKey, TValue>(
16-
this IDictionary<TKey, TValue> source,
17-
IComparer<TKey> comparer)
18-
where TKey : notnull
19-
{
20-
#if NET7_0_OR_GREATER
21-
ArgumentNullException.ThrowIfNull(nameof(source));
22-
ArgumentNullException.ThrowIfNull(nameof(comparer));
23-
#else
24-
if (source == null)
25-
throw new ArgumentNullException(nameof(source));
26-
if (comparer == null)
27-
throw new ArgumentNullException(nameof(comparer));
28-
#endif
29-
return source.OrderBy(kvp => kvp.Key, comparer)
30-
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
31-
}
32-
33-
/// <summary>
34-
/// Sorts any IEnumerable<T> using the specified comparer and returns a List</T>.
35-
/// </summary>
36-
internal static List<T> Sort<T>(this IEnumerable<T> source, IComparer<T> comparer)
37-
{
38-
#if NET7_0_OR_GREATER
39-
ArgumentNullException.ThrowIfNull(source);
40-
ArgumentNullException.ThrowIfNull(comparer);
41-
#else
42-
if (source == null)
43-
throw new ArgumentNullException(nameof(source));
44-
if (comparer == null)
45-
throw new ArgumentNullException(nameof(comparer));
46-
#endif
47-
return source.OrderBy(item => item, comparer).ToList();
48-
}
498
}
509
}

0 commit comments

Comments
 (0)