diff --git a/src/UglyToad.PdfPig.Core/ArrayPoolBufferWriter.cs b/src/UglyToad.PdfPig.Core/ArrayPoolBufferWriter.cs
index 1abd1172..96b385d8 100644
--- a/src/UglyToad.PdfPig.Core/ArrayPoolBufferWriter.cs
+++ b/src/UglyToad.PdfPig.Core/ArrayPoolBufferWriter.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Buffers;
+using System.Buffers;
namespace UglyToad.PdfPig.Core;
diff --git a/src/UglyToad.PdfPig.Core/IndirectReference.cs b/src/UglyToad.PdfPig.Core/IndirectReference.cs
index 39243dc2..d215bbb0 100644
--- a/src/UglyToad.PdfPig.Core/IndirectReference.cs
+++ b/src/UglyToad.PdfPig.Core/IndirectReference.cs
@@ -71,7 +71,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is IndirectReference other && Equals(other);
}
diff --git a/src/UglyToad.PdfPig.Core/OtherEncodings.cs b/src/UglyToad.PdfPig.Core/OtherEncodings.cs
index f4dbe3f6..c08db5d9 100644
--- a/src/UglyToad.PdfPig.Core/OtherEncodings.cs
+++ b/src/UglyToad.PdfPig.Core/OtherEncodings.cs
@@ -16,7 +16,7 @@
///
/// Convert the string to bytes using the ISO 8859-1 encoding.
///
- public static byte[] StringAsLatin1Bytes(string s)
+ public static byte[]? StringAsLatin1Bytes(string? s)
{
if (s == null)
{
diff --git a/src/UglyToad.PdfPig.Core/PdfDocEncoding.cs b/src/UglyToad.PdfPig.Core/PdfDocEncoding.cs
index 64080f71..43dbcec6 100644
--- a/src/UglyToad.PdfPig.Core/PdfDocEncoding.cs
+++ b/src/UglyToad.PdfPig.Core/PdfDocEncoding.cs
@@ -264,7 +264,7 @@
/// Try to convert raw bytes to a PdfDocEncoding encoded string. If unsupported characters are encountered
/// meaning we cannot safely round-trip the value to bytes this will instead return false.
///
- public static bool TryConvertBytesToString(ReadOnlySpan bytes, out string result)
+ public static bool TryConvertBytesToString(ReadOnlySpan bytes, out string? result)
{
result = null;
if (bytes.Length == 0)
diff --git a/src/UglyToad.PdfPig.Core/PdfLine.cs b/src/UglyToad.PdfPig.Core/PdfLine.cs
index 2428597f..fdff22f7 100644
--- a/src/UglyToad.PdfPig.Core/PdfLine.cs
+++ b/src/UglyToad.PdfPig.Core/PdfLine.cs
@@ -70,7 +70,7 @@
///
/// Returns a value indicating whether this is equal to a specified .
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is PdfLine other && Equals(other);
}
diff --git a/src/UglyToad.PdfPig.Core/PdfPoint.cs b/src/UglyToad.PdfPig.Core/PdfPoint.cs
index d6e9d33a..75abca58 100644
--- a/src/UglyToad.PdfPig.Core/PdfPoint.cs
+++ b/src/UglyToad.PdfPig.Core/PdfPoint.cs
@@ -83,7 +83,7 @@
///
/// Returns a value indicating whether this is equal to a specified .
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is PdfPoint other && Equals(other);
}
diff --git a/src/UglyToad.PdfPig.Core/PdfRectangle.cs b/src/UglyToad.PdfPig.Core/PdfRectangle.cs
index 4d312108..c7c14bde 100644
--- a/src/UglyToad.PdfPig.Core/PdfRectangle.cs
+++ b/src/UglyToad.PdfPig.Core/PdfRectangle.cs
@@ -177,7 +177,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is PdfRectangle other && Equals(other);
}
diff --git a/src/UglyToad.PdfPig.Core/PdfSubpath.cs b/src/UglyToad.PdfPig.Core/PdfSubpath.cs
index d5253258..b390f260 100644
--- a/src/UglyToad.PdfPig.Core/PdfSubpath.cs
+++ b/src/UglyToad.PdfPig.Core/PdfSubpath.cs
@@ -241,8 +241,8 @@
public bool IsClosed()
{
var filteredCount = 0;
- IPathCommand last = null;
- IPathCommand first = null;
+ IPathCommand? last = null;
+ IPathCommand? first = null;
for (int i = Commands.Count - 1; i >= 0; i--)
{
var cmd = Commands[i];
@@ -376,14 +376,14 @@
/// Gets a which entirely contains the geometry of the defined path.
///
/// For paths which don't define any geometry this returns .
- public static PdfRectangle? GetBoundingRectangle(IReadOnlyList path)
+ public static PdfRectangle? GetBoundingRectangle(IReadOnlyList? path)
{
if (path == null || path.Count == 0)
{
return null;
}
- var bboxes = path.Select(x => x.GetBoundingRectangle()).Where(x => x.HasValue).Select(x => x.Value).ToList();
+ var bboxes = path.Select(x => x.GetBoundingRectangle()).Where(x => x.HasValue).Select(x => x!.Value).ToList();
if (bboxes.Count == 0)
{
return null;
@@ -433,7 +433,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return (obj is Close);
}
@@ -479,7 +479,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is Move move)
{
@@ -545,7 +545,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is Line line)
{
@@ -651,7 +651,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is QuadraticBezierCurve curve)
{
@@ -809,7 +809,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is CubicBezierCurve curve)
{
@@ -944,7 +944,7 @@
///
/// Compares two s for equality. Paths will only be considered equal if the commands which construct the paths are in the same order.
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is PdfSubpath path) || Commands.Count != path.Commands.Count)
{
diff --git a/src/UglyToad.PdfPig.Core/TransformationMatrix.cs b/src/UglyToad.PdfPig.Core/TransformationMatrix.cs
index 8e270cfb..db6ab8e2 100644
--- a/src/UglyToad.PdfPig.Core/TransformationMatrix.cs
+++ b/src/UglyToad.PdfPig.Core/TransformationMatrix.cs
@@ -463,7 +463,7 @@
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is TransformationMatrix other && Equals(other);
}
diff --git a/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj b/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj
index 618c7d8e..56458989 100644
--- a/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj
+++ b/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj
@@ -7,6 +7,8 @@
true
true
..\pdfpig.snk
+ enable
+ nullable
diff --git a/src/UglyToad.PdfPig.Core/Union.cs b/src/UglyToad.PdfPig.Core/Union.cs
index 485f5dab..4aa124b6 100644
--- a/src/UglyToad.PdfPig.Core/Union.cs
+++ b/src/UglyToad.PdfPig.Core/Union.cs
@@ -89,7 +89,7 @@ namespace UglyToad.PdfPig.Core
///
public override bool TryGetSecond(out B b)
{
- b = default(B);
+ b = default!;
return false;
}
@@ -135,7 +135,7 @@ namespace UglyToad.PdfPig.Core
///
public override bool TryGetFirst(out A a)
{
- a = default(A);
+ a = default!;
return false;
}