From a3864c9de7aac2085cdfbfb181bac410583cb54f Mon Sep 17 00:00:00 2001 From: BobLd <38405645+BobLd@users.noreply.github.com> Date: Sun, 14 Sep 2025 16:34:43 +0100 Subject: [PATCH] Use record struct in FileHeaderOffset --- .../Parser/FileStructure/FileHeaderOffset.cs | 16 ++++++++-------- .../Polyfills/IsExternalInitPoly.cs | 6 ++++++ 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 src/UglyToad.PdfPig/Polyfills/IsExternalInitPoly.cs diff --git a/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderOffset.cs b/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderOffset.cs index e6dc4dd19..5e1ad45b8 100644 --- a/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderOffset.cs +++ b/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderOffset.cs @@ -4,14 +4,14 @@ /// How many bytes precede the "%PDF-" version header in the file. In some files this 'junk' can /// offset all following offset bytes. /// -internal readonly struct FileHeaderOffset(int value) +internal readonly record struct FileHeaderOffset(int Value) : IEquatable { - public int Value => value; + public override string ToString() => Value.ToString(); + + public bool Equals(FileHeaderOffset other) + { + return Value == other.Value; + } - public override string ToString() => value.ToString(); - - public override bool Equals(object? obj) => - obj is FileHeaderOffset other && value == other.Value; - - public override int GetHashCode() => value.GetHashCode(); + public override int GetHashCode() => Value.GetHashCode(); } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Polyfills/IsExternalInitPoly.cs b/src/UglyToad.PdfPig/Polyfills/IsExternalInitPoly.cs new file mode 100644 index 000000000..58f64aa63 --- /dev/null +++ b/src/UglyToad.PdfPig/Polyfills/IsExternalInitPoly.cs @@ -0,0 +1,6 @@ +#if !NET +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit { } +} +#endif \ No newline at end of file