Skip to content

Commit d516ca6

Browse files
committed
Fixed a few nullability issues
1 parent 585cedd commit d516ca6

File tree

6 files changed

+15
-37
lines changed

6 files changed

+15
-37
lines changed

src/Synercoding.Primitives/Point.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ public override int GetHashCode()
7171
=> HashCode.Combine(X, Y);
7272

7373
/// <inheritdoc />
74-
public override bool Equals(object obj)
75-
{
76-
return obj is Point unit && Equals(unit);
77-
}
74+
public override bool Equals(object? obj)
75+
=> obj is Point unit && Equals(unit);
7876

7977
/// <inheritdoc />
8078
public bool Equals(Point other)

src/Synercoding.Primitives/Rectangle.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,8 @@ public override int GetHashCode()
143143
=> HashCode.Combine(LLX, LLY, URX, URY);
144144

145145
/// <inheritdoc/>
146-
public override bool Equals(object obj)
147-
{
148-
return obj is Rectangle unit && Equals(unit);
149-
}
146+
public override bool Equals(object? obj)
147+
=> obj is Rectangle unit && Equals(unit);
150148

151149
/// <inheritdoc/>
152150
public bool Equals(Rectangle other)

src/Synercoding.Primitives/Size.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ public override int GetHashCode()
8383
=> HashCode.Combine(Width, Height);
8484

8585
/// <inheritdoc/>
86-
public override bool Equals(object obj)
87-
{
88-
return obj is Size unit && Equals(unit);
89-
}
86+
public override bool Equals(object? obj)
87+
=> obj is Size unit && Equals(unit);
9088

9189
/// <inheritdoc/>
9290
public bool Equals(Size other)

src/Synercoding.Primitives/Spacing.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ public override int GetHashCode()
105105
=> HashCode.Combine(Left, Top, Right, Bottom);
106106

107107
/// <inheritdoc/>
108-
public override bool Equals(object obj)
109-
{
110-
return obj is Spacing unit && Equals(unit);
111-
}
108+
public override bool Equals(object? obj)
109+
=> obj is Spacing unit && Equals(unit);
112110

113111
/// <inheritdoc/>
114112
public bool Equals(Spacing other)

src/Synercoding.Primitives/Unit.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ public override string ToString()
3939
=> $"{Designation.Shortform()} ({PerInch} per inch)";
4040

4141
/// <inheritdoc/>
42-
public override bool Equals(object obj)
43-
{
44-
if (obj is Unit unit)
45-
return Equals(unit);
46-
return false;
47-
}
42+
public override bool Equals(object? obj)
43+
=> obj is Unit unit && Equals(unit);
4844

4945
/// <inheritdoc/>
5046
public override int GetHashCode() => HashCode.Combine(PerInch, Designation);
@@ -55,21 +51,15 @@ public override bool Equals(object obj)
5551
/// <param name="left">The first value to compare.</param>
5652
/// <param name="right">The second value to compare.</param>
5753
/// <returns>true if left and right are equal; otherwise, false.</returns>
58-
public static bool operator ==(Unit left, Unit right)
59-
{
60-
return left.Equals(right);
61-
}
54+
public static bool operator ==(Unit left, Unit right) => left.Equals(right);
6255

6356
/// <summary>
6457
/// Returns a value that indicates whether two specified <see cref="Unit"/> values are not equal.
6558
/// </summary>
6659
/// <param name="left">The first value to compare.</param>
6760
/// <param name="right">The second value to compare.</param>
6861
/// <returns>true if left and right are not equal; otherwise, false.</returns>
69-
public static bool operator !=(Unit left, Unit right)
70-
{
71-
return !(left == right);
72-
}
62+
public static bool operator !=(Unit left, Unit right) => !( left == right );
7363

7464
/// <summary>
7565
/// Unit for millimeters

src/Synercoding.Primitives/UnitValue.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public UnitValue ConvertTo(Unit unit)
4848
}
4949

5050
/// <inheritdoc/>
51-
public int CompareTo(object obj)
51+
public int CompareTo(object? obj)
5252
{
5353
if (obj is UnitValue unitValue)
5454
return CompareTo(unitValue);
@@ -74,12 +74,8 @@ public override string ToString()
7474
=> $"{Value} {Unit.Designation.Shortform()}";
7575

7676
/// <inheritdoc/>
77-
public override bool Equals(object obj)
78-
{
79-
if (obj is UnitValue unit)
80-
return Equals(unit);
81-
return false;
82-
}
77+
public override bool Equals(object? obj)
78+
=> obj is UnitValue unit && Equals(unit);
8379

8480
/// <inheritdoc/>
8581
public bool Equals(UnitValue other)

0 commit comments

Comments
 (0)