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

JaCraig / Archivist / 19320779687

13 Nov 2025 04:42AM UTC coverage: 77.456% (-1.3%) from 78.739%
19320779687

push

github

JaCraig
feat(dependencies): update package versions

Update various package dependencies to their latest versions to ensure compatibility, security, and access to new features.

- Update `Microsoft.NET.Test.Sdk` to `18.0.1` in `Archivist.OCR.Tests.csproj` and `Archivist.Tests.csproj`.
- Update `Microsoft.CodeAnalysis.NetAnalyzers` to `10.0.100` in `Archivist.OCR.csproj` and `Archivist.csproj`.
- Update `Microsoft.Extensions.Logging` to `10.0.0` in `Archivist.Tests.csproj`.
- Update `Microsoft.Extensions.DependencyInjection` and `Microsoft.Extensions.Options` to `10.0.0` in `Archivist.csproj`.
- Update `ObjectCartographer` to `4.2.0` in `Archivist.csproj`.
- Update `System.Text.Encoding.CodePages` to `10.0.0` in `Archivist.csproj`.

2411 of 3412 branches covered (70.66%)

Branch coverage included in aggregate %.

3203 of 3836 relevant lines covered (83.5%)

6733.13 hits per line

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

84.55
/Archivist/DataTypes/KeyValueField.cs
1
using Archivist.Interfaces;
2
using ObjectCartographer;
3
using System;
4
using System.Collections.Generic;
5

6
namespace Archivist.DataTypes
7
{
8
    /// <summary>
9
    /// Represents a field in a card.
10
    /// </summary>
11
    public class KeyValueField : IEquatable<KeyValueField>, IComparable<KeyValueField>, IObjectConvertable
12
    {
13
        /// <summary>
14
        /// Initializes a new instance of the <see cref="KeyValueField"/> class.
15
        /// </summary>
16
        /// <param name="property">The property of the field.</param>
17
        /// <param name="parameters">The parameters of the field.</param>
18
        /// <param name="value">The value of the field.</param>
19
        public KeyValueField(string? property, IEnumerable<KeyValueParameter>? parameters, string? value)
693✔
20
        {
21
            Property = property ?? "";
693✔
22
            Parameters.AddRange(parameters ?? Array.Empty<KeyValueParameter>());
693✔
23
            Value = value ?? "";
693✔
24
        }
693✔
25

26
        /// <summary>
27
        /// Initializes a new instance of the <see cref="KeyValueField"/> class.
28
        /// </summary>
29
        /// <param name="field">The field to copy.</param>
30
        public KeyValueField(KeyValueField? field)
31
            : this(field?.Property, field?.Parameters, field?.Value)
12✔
32
        {
33
        }
12✔
34

35
        /// <summary>
36
        /// Gets or sets the parameter of the field (sub type).
37
        /// </summary>
38
        public List<KeyValueParameter> Parameters { get; } = new List<KeyValueParameter>();
1,800✔
39

40
        /// <summary>
41
        /// Gets or sets the property of the field (the type).
42
        /// </summary>
43
        public string Property { get; set; }
3,286✔
44

45
        /// <summary>
46
        /// Gets or sets the value of the field.
47
        /// </summary>
48
        public string? Value { get; set; }
1,480✔
49

50
        /// <summary>
51
        /// Determines whether two <see cref="KeyValueField"/> objects are not equal.
52
        /// </summary>
53
        /// <param name="left">The first <see cref="KeyValueField"/> to compare.</param>
54
        /// <param name="right">The second <see cref="KeyValueField"/> to compare.</param>
55
        /// <returns>
56
        /// <c>true</c> if the two <see cref="KeyValueField"/> objects are not equal; otherwise, <c>false</c>.
57
        /// </returns>
58
        public static bool operator !=(KeyValueField? left, KeyValueField? right)
59
        {
60
            return !(left == right);
6✔
61
        }
62

63
        /// <summary>
64
        /// Compares two <see cref="KeyValueField"/> objects and determines whether the first one is
65
        /// less than the second one.
66
        /// </summary>
67
        /// <param name="left">The first <see cref="KeyValueField"/> to compare.</param>
68
        /// <param name="right">The second <see cref="KeyValueField"/> to compare.</param>
69
        /// <returns>
70
        /// <c>true</c> if the first <see cref="KeyValueField"/> is less than the second one;
71
        /// otherwise, <c>false</c>.
72
        /// </returns>
73
        public static bool operator <(KeyValueField? left, KeyValueField? right)
74
        {
75
            return left is null ? right is not null : left.CompareTo(right) < 0;
4✔
76
        }
77

78
        /// <summary>
79
        /// Compares two <see cref="KeyValueField"/> objects and determines whether the first one is
80
        /// less than or equal to the second one.
81
        /// </summary>
82
        /// <param name="left">The first <see cref="KeyValueField"/> to compare.</param>
83
        /// <param name="right">The second <see cref="KeyValueField"/> to compare.</param>
84
        /// <returns>
85
        /// <c>true</c> if the first <see cref="KeyValueField"/> is less than or equal to the second
86
        /// one; otherwise, <c>false</c>.
87
        /// </returns>
88
        public static bool operator <=(KeyValueField? left, KeyValueField? right)
89
        {
90
            return left is null || left.CompareTo(right) <= 0;
4✔
91
        }
92

93
        /// <summary>
94
        /// Determines whether two <see cref="KeyValueField"/> objects are equal.
95
        /// </summary>
96
        /// <param name="left">The first <see cref="KeyValueField"/> to compare.</param>
97
        /// <param name="right">The second <see cref="KeyValueField"/> to compare.</param>
98
        /// <returns>
99
        /// <c>true</c> if the two <see cref="KeyValueField"/> objects are equal; otherwise, <c>false</c>.
100
        /// </returns>
101
        public static bool operator ==(KeyValueField? left, KeyValueField? right)
102
        {
103
            if (left is null)
12✔
104
                return right is null;
4✔
105
            return left.Equals(right);
8✔
106
        }
107

108
        /// <summary>
109
        /// Compares two <see cref="KeyValueField"/> objects and determines whether the first one is
110
        /// greater than the second one.
111
        /// </summary>
112
        /// <param name="left">The first <see cref="KeyValueField"/> to compare.</param>
113
        /// <param name="right">The second <see cref="KeyValueField"/> to compare.</param>
114
        /// <returns>
115
        /// <c>true</c> if the first <see cref="KeyValueField"/> is greater than the second one;
116
        /// otherwise, <c>false</c>.
117
        /// </returns>
118
        public static bool operator >(KeyValueField? left, KeyValueField? right)
119
        {
120
            return left?.CompareTo(right) > 0;
3✔
121
        }
122

123
        /// <summary>
124
        /// Compares two <see cref="KeyValueField"/> objects and determines whether the first one is
125
        /// greater than or equal to the second one.
126
        /// </summary>
127
        /// <param name="left">The first <see cref="KeyValueField"/> to compare.</param>
128
        /// <param name="right">The second <see cref="KeyValueField"/> to compare.</param>
129
        /// <returns>
130
        /// <c>true</c> if the first <see cref="KeyValueField"/> is greater than or equal to the
131
        /// second one; otherwise, <c>false</c>.
132
        /// </returns>
133
        public static bool operator >=(KeyValueField? left, KeyValueField? right)
134
        {
135
            return left is null ? right is null : left.CompareTo(right) >= 0;
5✔
136
        }
137

138
        /// <summary>
139
        /// Compares the current <see cref="KeyValueField"/> object with another <see
140
        /// cref="KeyValueField"/> object and returns an integer that indicates whether the current
141
        /// object precedes, follows, or occurs in the same position in the sort order as the other object.
142
        /// </summary>
143
        /// <param name="other">
144
        /// The <see cref="KeyValueField"/> object to compare with the current object.
145
        /// </param>
146
        /// <returns>
147
        /// A value that indicates the relative order of the objects being compared. The return
148
        /// value has the following meanings: Value Meaning Less than zero This object is less than
149
        /// the <paramref name="other"/> parameter. Zero This object is equal to <paramref
150
        /// name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
151
        /// </returns>
152
        public int CompareTo(KeyValueField? other)
153
        {
154
            if (ReferenceEquals(this, other))
13!
155
                return 0;
×
156
            if (other is null)
13✔
157
                return 1;
5✔
158
            var ReturnValue = other.Property?.CompareTo(Property) ?? 1;
8!
159
            if (ReturnValue != 0)
8✔
160
                return ReturnValue;
7✔
161
            ReturnValue = other.Parameters.Count.CompareTo(Parameters.Count);
1✔
162
            if (ReturnValue != 0)
1!
163
                return ReturnValue;
×
164
            foreach (KeyValueParameter Parameter in Parameters)
8✔
165
            {
166
                ReturnValue = other.Parameters.Contains(Parameter) ? 0 : 1;
3✔
167
                if (ReturnValue != 0)
3!
168
                    return ReturnValue;
×
169
            }
170
            return other.Value?.CompareTo(Value) ?? 1;
1!
171
        }
×
172

173
        /// <summary>
174
        /// Converts the object to a string and sets the content of the field.
175
        /// </summary>
176
        /// <typeparam name="TObject">Object type</typeparam>
177
        /// <param name="obj">Object to convert</param>
178
        public void ConvertFrom<TObject>(TObject obj) => Value = obj?.ToString() ?? "";
2✔
179

180
        /// <summary>
181
        /// Converts the content of the field to the specified type.
182
        /// </summary>
183
        /// <typeparam name="TObject">The type to convert the content to.</typeparam>
184
        /// <returns>The converted content of the field.</returns>
185
        public TObject? ConvertTo<TObject>() => Value.To<TObject>();
2✔
186

187
        /// <summary>
188
        /// Determines whether the specified object is equal to the current <see
189
        /// cref="KeyValueField"/> object.
190
        /// </summary>
191
        /// <param name="obj">The object to compare with the current object.</param>
192
        /// <returns>
193
        /// <c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.
194
        /// </returns>
195
        public override bool Equals(object? obj) => ReferenceEquals(this, obj) || (obj is KeyValueField CardFieldObject && Equals(CardFieldObject));
6!
196

197
        /// <summary>
198
        /// Determines whether the specified <see cref="KeyValueField"/> object is equal to the
199
        /// current <see cref="KeyValueField"/> object.
200
        /// </summary>
201
        /// <param name="other">
202
        /// The <see cref="KeyValueField"/> object to compare with the current object.
203
        /// </param>
204
        /// <returns>
205
        /// <c>true</c> if the specified <see cref="KeyValueField"/> object is equal to the current
206
        /// object; otherwise, <c>false</c>.
207
        /// </returns>
208
        public bool Equals(KeyValueField? other)
209
        {
210
            if (other is null)
14✔
211
                return false;
3✔
212
            if (ReferenceEquals(this, other))
11!
213
                return true;
×
214
            if (Property != other.Property)
11✔
215
                return false;
7✔
216
            if (Value != other.Value)
4!
217
                return false;
×
218
            if (Parameters.Count != other.Parameters.Count)
4!
219
                return false;
×
220
            foreach (KeyValueParameter Parameter in Parameters)
32✔
221
            {
222
                if (!other.Parameters.Contains(Parameter))
12!
223
                    return false;
×
224
            }
225
            return true;
4✔
226
        }
×
227

228
        /// <summary>
229
        /// Returns the hash code for the current <see cref="KeyValueField"/> object.
230
        /// </summary>
231
        /// <returns>A 32-bit signed integer hash code.</returns>
232
        public override int GetHashCode()
233
        {
234
            var HashCode = new HashCode();
6✔
235
            HashCode.Add(Property);
6✔
236
            HashCode.Add(Value);
6✔
237
            foreach (KeyValueParameter Parameter in Parameters)
48✔
238
            {
239
                HashCode.Add(Parameter);
18✔
240
            }
241
            return HashCode.ToHashCode();
6✔
242
        }
243

244
        /// <summary>
245
        /// Returns a string representation of the card field.
246
        /// </summary>
247
        /// <returns>A string representation of the card field.</returns>
248
        public override string ToString() => $"{Property} ({string.Join(';', Parameters)}): {Value}";
292✔
249
    }
250
}
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

© 2025 Coveralls, Inc