Skip to content

Commit 913cf9c

Browse files
committed
Seal PdfSubpath class and IPathCommand implementations, fix Close.GetHashCode() and fix #1027
1 parent 24902f1 commit 913cf9c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/UglyToad.PdfPig.Core/PdfSubpath.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// <summary>
99
/// A supbpath is made up of a sequence of connected segments.
1010
/// </summary>
11-
public class PdfSubpath
11+
public sealed class PdfSubpath
1212
{
1313
private readonly List<IPathCommand> commands = new List<IPathCommand>();
1414

@@ -416,8 +416,10 @@ public interface IPathCommand
416416
/// <summary>
417417
/// Close the current <see cref="PdfSubpath"/>.
418418
/// </summary>
419-
public class Close : IPathCommand
419+
public sealed class Close : IPathCommand
420420
{
421+
private static readonly int _hash = typeof(Close).GetHashCode();
422+
421423
/// <inheritdoc />
422424
public PdfRectangle? GetBoundingRectangle()
423425
{
@@ -439,15 +441,14 @@ public override bool Equals(object obj)
439441
/// <inheritdoc />
440442
public override int GetHashCode()
441443
{
442-
// ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode
443-
return base.GetHashCode();
444+
return _hash;
444445
}
445446
}
446447

447448
/// <summary>
448449
/// Move drawing of the current <see cref="PdfSubpath"/> to the specified location.
449450
/// </summary>
450-
public class Move : IPathCommand
451+
public sealed class Move : IPathCommand
451452
{
452453
/// <summary>
453454
/// The location to move to.
@@ -497,7 +498,7 @@ public override int GetHashCode()
497498
/// <summary>
498499
/// Draw a straight line between two points.
499500
/// </summary>
500-
public class Line : IPathCommand
501+
public sealed class Line : IPathCommand
501502
{
502503
/// <summary>
503504
/// The start of the line.

0 commit comments

Comments
 (0)