< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 54
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Select()0%220%
OrderBy()0%440%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/EnumerableExtensions.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Collections.Generic;
 5
 6namespace System.Reflection.Internal
 7{
 8    /// <summary>
 9    /// Replacements for System.Linq to avoid an unnecessary dependency.
 10    /// Parameter and return types strengthened to actual internal usage as an optimization.
 11    /// </summary>
 12    internal static class EnumerableExtensions
 13    {
 14        // used only in debugger display so we needn't get fancy with optimizations.
 15        public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TRes
 016        {
 017            foreach (var item in source)
 018            {
 019                yield return selector(item);
 020            }
 021        }
 22
 23        public static IEnumerable<T> OrderBy<T>(this List<T> source, Comparison<T> comparison)
 024        {
 25            // Produce an iterator that represents a stable sort of source.
 26            // Implement by creating an int array that represents the initial ordering of elements in
 27            // the source list, then sort those integers with a sort function that sorts by the values
 28            // in source, but for cases where the values are equivalent, sort by initial index in
 29            // the source array
 030            int[] map = new int[source.Count];
 031            for (int i = 0; i < map.Length; i++)
 032                map[i] = i;
 33
 034            Array.Sort(map, (int left, int right) =>
 035            {
 036                if (left == right)
 037                    return 0;
 038
 039                int result = comparison(source[left], source[right]);
 040                if (result == 0)
 041                {
 042                    return left - right;
 043                }
 044                return result;
 045            });
 46
 047            foreach (int index in map)
 048            {
 049                yield return source[index];
 050            }
 051        }
 52    }
 53}
 54

Methods/Properties

Select()
OrderBy()