Skip to content

Commit

Permalink
cleanup for struct change
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Nov 19, 2024
1 parent f39c232 commit 04cbbe7
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,11 @@ public override int GetHashCode()

public static bool operator ==(DrawingBoxSymbol left, DrawingBoxSymbol right)
{
if ((object)left is null) return (object)right is null;
return left.Equals(right);
}

public static bool operator !=(DrawingBoxSymbol left, DrawingBoxSymbol right)
{
if ((object)left is null) return (object)right is not null;
return !left!.Equals(right);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public Pixel(PixelForeground foreground,

public bool Equals(Pixel other)
{
if ((object)other == null)
return false;

return Foreground.Equals(other.Foreground) &&
Background.Equals(other.Background) &&
IsCaret.Equals(other.IsCaret);
Expand Down Expand Up @@ -179,14 +176,11 @@ public override int GetHashCode()

public static bool operator ==(Pixel left, Pixel right)
{
if ((object)left is null) return (object)right is null;

return left.Equals(right);
}

public static bool operator !=(Pixel left, Pixel right)
{
if ((object)left is null) return (object)right is not null;
return !left.Equals(right);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public PixelBackground(PixelBackgroundMode mode, Color? color = null)

public bool Equals(PixelBackground other)
{
if ((object)other is null) return false;
return Color.Equals(other.Color) && Mode == other.Mode;
}

Expand Down Expand Up @@ -74,13 +73,11 @@ public override int GetHashCode()

public static bool operator ==(PixelBackground left, PixelBackground right)
{
if ((object)left is null) return (object)right is null;
return left.Equals(right);
}

public static bool operator !=(PixelBackground left, PixelBackground right)
{
if ((object)left == null) return (object)right != null;
return !left.Equals(right);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public PixelForeground(ISymbol symbol, Color color,

public bool Equals(PixelForeground other)
{
if ((object)other is null) return false;

return Symbol.Equals(other.Symbol) &&
Color.Equals(other.Color) &&
Weight.Equals(other.Weight) &&
Expand Down Expand Up @@ -88,13 +86,11 @@ public override int GetHashCode()

public static bool operator ==(PixelForeground left, PixelForeground right)
{
if ((object)left is null) return (object)right is null;
return left.Equals(right);
}

public static bool operator !=(PixelForeground left, PixelForeground right)
{
if ((object)left is null) return (object)right is not null;
return !left.Equals(right);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public SimpleSymbol(Rune rune)

public bool Equals(SimpleSymbol other)
{
if ((object)other is null)
return false;

return Text.Equals(other.Text, StringComparison.Ordinal);
}

Expand Down Expand Up @@ -70,14 +67,11 @@ public override int GetHashCode()

public static bool operator ==(SimpleSymbol left, SimpleSymbol right)
{
if ((object)left is null) return (object)right is null;
return left.Equals(right);
}

public static bool operator !=(SimpleSymbol left, SimpleSymbol right)
{
if ((object)left is null) return (object)right is not null;

return !left.Equals(right);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void WritePixel(
// want to output as they are already invisible and represented
// by the complex glyph coming before it (aka double-wide chars)
if (pixel.Foreground.Symbol.Width > 0)
_stringBuilder.Append(pixel.Foreground.Symbol!.Text);
_stringBuilder.Append(pixel.Foreground.Symbol.Text);

_currentBufferPoint = _currentBufferPoint.WithXpp();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/Consolonia.Core.Tests/DrawingContextImplTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void DrawDoubleWide()
else if (x == 6)
{
Assert.IsTrue(pixel.Width == 0);
Assert.IsTrue(pixel.Foreground.Symbol!.Text.Length == 0);
Assert.IsTrue(pixel.Foreground.Symbol.Text.Length == 0);
}
else
{
Expand Down Expand Up @@ -141,7 +141,7 @@ public void DrawOverDoubleWideFirstChar()
else if (x == 6)
{
Assert.IsTrue(pixel.Width == 1);
Assert.IsTrue(pixel.Foreground.Symbol!.Text == " ");
Assert.IsTrue(pixel.Foreground.Symbol.Text == " ");
}
else
{
Expand Down Expand Up @@ -173,7 +173,7 @@ public void DrawOverDoubleWideSecondChar()
else if (x == 6)
{
Assert.IsTrue(pixel.Width == 1);
Assert.IsTrue(pixel.Foreground.Symbol!.Text == "X");
Assert.IsTrue(pixel.Foreground.Symbol.Text == "X");
Assert.IsTrue(pixel.Foreground.Color == Colors.Red);
}
else
Expand Down

0 comments on commit 04cbbe7

Please sign in to comment.