• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SamboyCoding / Cpp2IL / 15043826298

15 May 2025 11:30AM UTC coverage: 34.593% (-0.2%) from 34.797%
15043826298

push

github

SamboyCoding
Only set class layout for structs

1790 of 6496 branches covered (27.56%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 1 file covered. (100.0%)

18 existing lines in 3 files now uncovered.

4143 of 10655 relevant lines covered (38.88%)

161070.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.67
/LibCpp2IL/Extensions.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4

5
namespace LibCpp2IL;
6

7
public static class Extensions
8
{
9
    public static T[] SubArray<T>(this T[] data, int index, int length)
10
    {
11
        var result = new T[length];
21,164✔
12
        Array.Copy(data, index, result, 0, length);
21,164✔
13
        return result;
21,164✔
14
    }
15

16
    public static T RemoveAndReturn<T>(this List<T> data, int index)
17
    {
18
        var result = data[index];
×
19
        data.RemoveAt(index);
×
20
        return result;
×
21
    }
22

23
    public static string Repeat(this string source, int count)
24
    {
UNCOV
25
        var res = new StringBuilder();
×
UNCOV
26
        for (var i = 0; i < count; i++)
×
27
        {
UNCOV
28
            res.Append(source);
×
29
        }
30

UNCOV
31
        return res.ToString();
×
32
    }
33

34
    public static string ToStringEnumerable<T>(this IEnumerable<T> enumerable)
35
    {
36
        var builder = new StringBuilder("[");
×
37
        builder.Append(string.Join(", ", enumerable));
×
38
        builder.Append("]");
×
39
        return builder.ToString();
×
40
    }
41

42
    public static TValue? GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue? defaultValue)
43
    {
44
        if (dictionary == null)
722,811!
45
        {
46
            throw new ArgumentNullException(nameof(dictionary));
×
47
        }
48

49
        return dictionary.TryGetValue(key, out var value) ? value : defaultValue;
722,811!
50
    }
51

52
    public static TValue? GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) => dictionary.GetOrDefault(key, default);
111,270✔
53

54
    public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey one, out TValue two)
55
    {
56
        one = pair.Key;
×
57
        two = pair.Value;
×
58
    }
×
59

60
    public static uint Bits(this uint x, int low, int count) => (x >> low) & (uint)((1 << count) - 1);
×
61

62
    public static bool TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value) where TKey : notnull
63
    {
64
        if (dictionary.ContainsKey(key))
×
65
            return false;
×
66

67
        dictionary.Add(key, value);
×
68

69
        return true;
×
70
    }
71

72
    /// <summary>
73
    /// Sorts in ascending order using the provided key function
74
    /// </summary>
75
    public static void SortByExtractedKey<T, K>(this List<T> list, Func<T, K> keyObtainer) where K : IComparable<K>
76
    {
77
        list.Sort((a, b) =>
×
78
        {
×
79
            var aKey = keyObtainer(a);
×
80
            var bKey = keyObtainer(b);
×
81

×
82
            return aKey.CompareTo(bKey);
×
83
        });
×
84
    }
×
85

86
    public static int ParseDigit(this char c)
87
    {
88
        var ret = c - '0';
×
89
        if (ret > 9)
×
90
            throw new($"Invalid digit {c}");
×
91

92
        return ret;
×
93
    }
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc