Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
internal readonly struct FileHeaderOffset(int value)
internal readonly record struct FileHeaderOffset(int Value) : IEquatable<FileHeaderOffset>
{
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't record structs provide these default implementations already?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, including the IEquatable implementation. See .NET Lab

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do, but with default implementation. It's seems to be more efficient for speed to provide it when possible. Ill provide the source of that shortly

Copy link
Collaborator Author

@BobLd BobLd Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
6 changes: 6 additions & 0 deletions src/UglyToad.PdfPig/Polyfills/IsExternalInitPoly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#if !NET
namespace System.Runtime.CompilerServices
{
internal static class IsExternalInit { }
}
#endif
Loading