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

ImmediatePlatform / Immediate.Apis / 28685339280

03 Jul 2026 10:06PM UTC coverage: 92.634% (+1.0%) from 91.678%
28685339280

push

github

web-flow
Upgrade `.net10.0` generator to net10 tfm (#303)

14 of 15 new or added lines in 12 files covered. (93.33%)

1333 of 1439 relevant lines covered (92.63%)

3.71 hits per line

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

65.63
/src/Immediate.Apis.Generators/EquatableDictionary.cs
1
namespace Immediate.Apis.Generators;
2

3
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
4

5
public static class EquatableDictionary
6
{
7
        public static EquatableDictionary<TKey, TValue> ToEquatableDictionary<TKey, TValue>(
8
                this IReadOnlyDictionary<TKey, TValue>? dict
9
        )
10
                where TValue : IEquatable<TValue>
11
        {
12
                return new(dict);
4✔
13
        }
14
}
15

16
public readonly struct EquatableDictionary<TKey, TValue>(
17
        IReadOnlyDictionary<TKey, TValue>? dictionary
18
) : IEquatable<EquatableDictionary<TKey, TValue>>
19
                where TValue : IEquatable<TValue>
20
{
21
        private readonly IReadOnlyDictionary<TKey, TValue>? _dictionary = dictionary;
4✔
22
        private readonly int _hashCode = BuildHashCode(dictionary);
4✔
23

24
        private static int BuildHashCode(IReadOnlyDictionary<TKey, TValue>? dictionary)
25
        {
26
                if (dictionary is null)
4✔
27
                        return new HashCode().ToHashCode();
×
28

29
                var hashCode = new HashCode();
4✔
30

31
                foreach (var kvp in dictionary.OrderBy(kvp => kvp.Key))
4✔
32
                {
33
                        hashCode.Add(kvp.Key);
4✔
34
                        hashCode.Add(kvp.Value);
4✔
35
                }
36

37
                return hashCode.ToHashCode();
4✔
38
        }
39

40
        public bool Equals(EquatableDictionary<TKey, TValue> other) =>
41
                ReferenceEquals(_dictionary, other._dictionary)
4✔
42
                        || (GetHashCode() == other.GetHashCode()
4✔
43
                                // both null is covered by reference equals
4✔
44
                                // only one null covered by different hash codes
4✔
45
                                && _dictionary!.Count == other._dictionary!.Count
4✔
46
                                && _dictionary
4✔
47
                                        .All(kvp =>
4✔
48
                                                other._dictionary.TryGetValue(kvp.Key, out var oValue)
×
49
                                                        && EqualityComparer<TValue>.Default.Equals(kvp.Value, oValue)
×
50
                                        )
4✔
51
                                );
4✔
52

53
        public override bool Equals(object? obj) =>
54
                obj is EquatableDictionary<TKey, TValue> dict && Equals(dict);
×
55

56
        public override int GetHashCode() => _hashCode;
×
57

58
        public static bool operator ==(EquatableDictionary<TKey, TValue> left, EquatableDictionary<TKey, TValue> right) =>
59
                left.Equals(right);
×
60

61
        public static bool operator !=(EquatableDictionary<TKey, TValue> left, EquatableDictionary<TKey, TValue> right) =>
62
                !(left == right);
×
63

64
        public bool TryGetValue(TKey key, out TValue? value)
65
        {
66
                if (_dictionary is { })
×
67
                        return _dictionary.TryGetValue(key, out value);
×
68

NEW
69
                value = default;
×
70
                return false;
×
71
        }
72

73
        public TValue GetValueOrDefault(TKey key)
74
        {
75
                if (_dictionary is { } && _dictionary.TryGetValue(key, out var value))
4✔
76
                        return value;
4✔
77

78
                return default!;
4✔
79
        }
80
}
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