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

KSP-CKAN / CKAN / 25198663652

01 May 2026 01:58AM UTC coverage: 87.472% (+1.6%) from 85.851%
25198663652

push

github

HebaruSan
Merge #4594 Windows dark mode in .NET 10 build

1982 of 2112 branches covered (93.84%)

Branch coverage included in aggregate %.

35 of 36 new or added lines in 7 files covered. (97.22%)

33 existing lines in 24 files now uncovered.

8491 of 9861 relevant lines covered (86.11%)

2.69 hits per line

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

92.68
/Core/Configuration/StabilityToleranceConfig.cs
1
using System;
2
using System.IO;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5

6
using Newtonsoft.Json;
7

8
using CKAN.Extensions;
9

10
namespace CKAN.Configuration
11
{
12
    [JsonObject(MemberSerialization.OptIn)]
13
    public class StabilityToleranceConfig : IEquatable<StabilityToleranceConfig>
14
    {
15
        public StabilityToleranceConfig(string path)
3✔
16
        {
17
            this.path = path;
3✔
18
            try
19
            {
20
                JsonConvert.PopulateObject(File.ReadAllText(this.path), this);
3✔
21
            }
3✔
22
            catch
3✔
23
            {
24
                // File doesn't exist yet, we can create it at save
25
            }
3✔
26
        }
3✔
27

28
        public StabilityToleranceConfig(StabilityToleranceConfig orig)
3✔
29
        {
30
            path = orig.path;
3✔
31
            overallStabilityTolerance = orig.overallStabilityTolerance;
3✔
32
            modStabilityTolerance = new SortedDictionary<string, ReleaseStatus>(
3✔
33
                                        orig.modStabilityTolerance);
34
        }
3✔
35

36
        public bool Save()
37
        {
38
            try
39
            {
40
                JsonConvert.SerializeObject(this, Formatting.Indented)
3✔
41
                           .WriteThroughTo(path);
42
                return true;
3✔
43
            }
44
            catch
×
45
            {
46
                return false;
×
47
            }
48
        }
3✔
49

50
        public ReleaseStatus? ModStabilityTolerance(string identifier)
51
            => modStabilityTolerance.TryGetValue(identifier, out ReleaseStatus relStat)
3✔
52
                   ? relStat
53
                   : null;
54

55
        public void SetModStabilityTolerance(string identifier, ReleaseStatus? relStat)
56
        {
57
            if (relStat is ReleaseStatus rs)
3✔
58
            {
59
                modStabilityTolerance[identifier] = rs;
3✔
60
            }
61
            else
62
            {
63
                modStabilityTolerance.Remove(identifier);
3✔
64
            }
65
            Changed?.Invoke(identifier, relStat);
3✔
66
            Save();
3✔
67
        }
3✔
68

69
        public ReleaseStatus OverallStabilityTolerance
70
        {
71
            get => overallStabilityTolerance;
3✔
72
            set
73
            {
74
                overallStabilityTolerance = value;
3✔
75
                Save();
3✔
76
                Changed?.Invoke(null, value);
3✔
UNCOV
77
            }
×
78
        }
79

80
        public IReadOnlyCollection<string> OverriddenModIdentifiers => modStabilityTolerance.Keys;
3✔
81

82
        public event Action<string?, ReleaseStatus?>? Changed;
83

84
        public override bool Equals(object? other)
85
            => Equals(other as StabilityToleranceConfig);
3✔
86

87
        public bool Equals(StabilityToleranceConfig? other)
88
            => other != null
3✔
89
               && overallStabilityTolerance == other?.overallStabilityTolerance
90
               && modStabilityTolerance.DictionaryEquals(other.modStabilityTolerance);
91

92
        public static bool operator ==(StabilityToleranceConfig? left,
93
                                       StabilityToleranceConfig? right)
94
            => Equals(left, right);
3✔
95

96
        public static bool operator !=(StabilityToleranceConfig? left,
97
                                       StabilityToleranceConfig? right)
98
            => !Equals(left, right);
3✔
99

100
        public override int GetHashCode()
101
            => (overallStabilityTolerance, modStabilityTolerance.DictionaryHashcode()).GetHashCode();
3✔
102

103
        [JsonProperty("overall_stability_tolerance", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
104
        [DefaultValue(ReleaseStatus.stable)]
105
        private ReleaseStatus overallStabilityTolerance = ReleaseStatus.stable;
106

107
        [JsonProperty("mod_stability_tolerance", NullValueHandling = NullValueHandling.Ignore)]
108
        private readonly SortedDictionary<string, ReleaseStatus> modStabilityTolerance =
3✔
109
            new SortedDictionary<string, ReleaseStatus>();
110

111
        [JsonIgnore]
112
        private readonly string path;
113
    }
114
}
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