From 435da86a25d2e389b844b1cdf3c2c079b78d7263 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 1 Apr 2024 19:13:44 -0700 Subject: [PATCH] Make QuadPointsQuadrilateral a readonly struct --- src/UglyToad.PdfPig/Annotations/AnnotationProvider.cs | 6 +++--- .../Annotations/QuadPointsQuadrilateral.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/UglyToad.PdfPig/Annotations/AnnotationProvider.cs b/src/UglyToad.PdfPig/Annotations/AnnotationProvider.cs index 2ce4dacb..02fc7c4a 100644 --- a/src/UglyToad.PdfPig/Annotations/AnnotationProvider.cs +++ b/src/UglyToad.PdfPig/Annotations/AnnotationProvider.cs @@ -115,13 +115,13 @@ if (values.Count == 8) { - quadPointRectangles.Add(new QuadPointsQuadrilateral(new[] - { + quadPointRectangles.Add(new QuadPointsQuadrilateral( + [ matrix.Transform(new PdfPoint(values[0], values[1])), matrix.Transform(new PdfPoint(values[2], values[3])), matrix.Transform(new PdfPoint(values[4], values[5])), matrix.Transform(new PdfPoint(values[6], values[7])) - })); + ])); values.Clear(); } diff --git a/src/UglyToad.PdfPig/Annotations/QuadPointsQuadrilateral.cs b/src/UglyToad.PdfPig/Annotations/QuadPointsQuadrilateral.cs index 5b11e881..e39973be 100644 --- a/src/UglyToad.PdfPig/Annotations/QuadPointsQuadrilateral.cs +++ b/src/UglyToad.PdfPig/Annotations/QuadPointsQuadrilateral.cs @@ -8,7 +8,7 @@ /// A QuadPoints quadrilateral is four points defining the region for an annotation to use. /// An annotation may cover multiple quadrilaterals. /// - public class QuadPointsQuadrilateral + public readonly struct QuadPointsQuadrilateral { /// /// The 4 points defining this quadrilateral. @@ -21,16 +21,16 @@ /// /// Create a new . /// - public QuadPointsQuadrilateral(IReadOnlyList points) + public QuadPointsQuadrilateral(PdfPoint[] points) { if (points is null) { throw new ArgumentNullException(nameof(points)); } - if (points.Count != 4) + if (points.Length != 4) { - throw new ArgumentException($"Quadpoints quadrilateral should only contain 4 points, instead got {points.Count} points."); + throw new ArgumentException($"Quadpoints quadrilateral should only contain 4 points, instead got {points.Length} points."); } Points = points;