Skip to content

Commit 90f9a72

Browse files
committed
CodeQA (again)
1 parent fe27db8 commit 90f9a72

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Hi3Helper.Core/Data/IniValue.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
44
using System.Globalization;
55
// ReSharper disable GrammarMistakeInComment
66
// ReSharper disable CommentTypo
7+
// ReSharper disable CheckNamespace
78

89
#nullable enable
910
namespace Hi3Helper.Data
1011
{
11-
public struct IniValue
12+
public struct IniValue : IEquatable<IniValue>
1213
{
1314
#region Fields
1415
private string? _value;
15-
private bool _isEmpty = true;
16+
1617
#endregion
1718

1819
#region Methods
1920
public string? Value
2021
{
2122
get => _value;
22-
set => _isEmpty = string.IsNullOrEmpty(_value = value);
23+
set => IsEmpty = string.IsNullOrEmpty(_value = value);
2324
}
2425

25-
public bool IsEmpty => _isEmpty;
26+
public bool IsEmpty { get; private set; } = true;
27+
2628
#endregion
2729

2830
#region Constructors
@@ -189,7 +191,7 @@ public Size ToSize()
189191
public readonly Guid ToGuid()
190192
{
191193
// If the back value is empty, return an empty Guid
192-
if (_isEmpty)
194+
if (IsEmpty)
193195
{
194196
return Guid.Empty;
195197
}
@@ -220,7 +222,7 @@ public bool ToBool(bool defaultValue = false)
220222
public bool? ToBoolNullable()
221223
{
222224
// If the value is empty, return null
223-
if (_isEmpty)
225+
if (IsEmpty)
224226
{
225227
return null;
226228
}
@@ -427,6 +429,8 @@ public TNumber ToNumber<TNumber>(TNumber? defaultValue = null)
427429

428430
public static bool operator !=(IniValue valueA, IniValue valueB) => !(valueA == valueB);
429431

432+
public bool Equals(IniValue compareTo) => this == compareTo;
433+
430434
public override bool Equals([NotNullWhen(true)] object? obj) => obj is IniValue iniValue && GetHashCode() == iniValue.GetHashCode();
431435

432436
public override int GetHashCode() => Value?.GetHashCode() ?? 0;

0 commit comments

Comments
 (0)