Skip to content

Commit 0ebbe05

Browse files
authored
add nullability to core projec (UglyToad#1111)
1 parent 52c0635 commit 0ebbe05

File tree

11 files changed

+22
-21
lines changed

11 files changed

+22
-21
lines changed

src/UglyToad.PdfPig.Core/ArrayPoolBufferWriter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Buffers;
1+
using System.Buffers;
32

43
namespace UglyToad.PdfPig.Core;
54

src/UglyToad.PdfPig.Core/IndirectReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public bool Equals(IndirectReference other)
7171
}
7272

7373
/// <inheritdoc />
74-
public override bool Equals(object obj)
74+
public override bool Equals(object? obj)
7575
{
7676
return obj is IndirectReference other && Equals(other);
7777
}

src/UglyToad.PdfPig.Core/OtherEncodings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class OtherEncodings
1616
/// <summary>
1717
/// Convert the string to bytes using the ISO 8859-1 encoding.
1818
/// </summary>
19-
public static byte[] StringAsLatin1Bytes(string s)
19+
public static byte[]? StringAsLatin1Bytes(string? s)
2020
{
2121
if (s == null)
2222
{

src/UglyToad.PdfPig.Core/PdfDocEncoding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static PdfDocEncoding()
264264
/// Try to convert raw bytes to a PdfDocEncoding encoded string. If unsupported characters are encountered
265265
/// meaning we cannot safely round-trip the value to bytes this will instead return false.
266266
/// </summary>
267-
public static bool TryConvertBytesToString(ReadOnlySpan<byte> bytes, out string result)
267+
public static bool TryConvertBytesToString(ReadOnlySpan<byte> bytes, out string? result)
268268
{
269269
result = null;
270270
if (bytes.Length == 0)

src/UglyToad.PdfPig.Core/PdfLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public PdfRectangle GetBoundingRectangle()
7070
/// <summary>
7171
/// Returns a value indicating whether this <see cref="PdfLine"/> is equal to a specified <see cref="PdfLine"/> .
7272
/// </summary>
73-
public override bool Equals(object obj)
73+
public override bool Equals(object? obj)
7474
{
7575
return obj is PdfLine other && Equals(other);
7676
}

src/UglyToad.PdfPig.Core/PdfPoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public PdfPoint Translate(double dx, double dy)
8383
/// <summary>
8484
/// Returns a value indicating whether this <see cref="PdfPoint"/> is equal to a specified <see cref="PdfPoint"/> .
8585
/// </summary>
86-
public override bool Equals(object obj)
86+
public override bool Equals(object? obj)
8787
{
8888
return obj is PdfPoint other && Equals(other);
8989
}

src/UglyToad.PdfPig.Core/PdfRectangle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public bool Equals(PdfRectangle other)
177177
}
178178

179179
/// <inheritdoc />
180-
public override bool Equals(object obj)
180+
public override bool Equals(object? obj)
181181
{
182182
return obj is PdfRectangle other && Equals(other);
183183
}

src/UglyToad.PdfPig.Core/PdfSubpath.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ public void CloseSubpath()
241241
public bool IsClosed()
242242
{
243243
var filteredCount = 0;
244-
IPathCommand last = null;
245-
IPathCommand first = null;
244+
IPathCommand? last = null;
245+
IPathCommand? first = null;
246246
for (int i = Commands.Count - 1; i >= 0; i--)
247247
{
248248
var cmd = Commands[i];
@@ -376,14 +376,14 @@ public bool IsClosed()
376376
/// Gets a <see cref="PdfRectangle"/> which entirely contains the geometry of the defined path.
377377
/// </summary>
378378
/// <returns>For paths which don't define any geometry this returns <see langword="null"/>.</returns>
379-
public static PdfRectangle? GetBoundingRectangle(IReadOnlyList<PdfSubpath> path)
379+
public static PdfRectangle? GetBoundingRectangle(IReadOnlyList<PdfSubpath>? path)
380380
{
381381
if (path == null || path.Count == 0)
382382
{
383383
return null;
384384
}
385385

386-
var bboxes = path.Select(x => x.GetBoundingRectangle()).Where(x => x.HasValue).Select(x => x.Value).ToList();
386+
var bboxes = path.Select(x => x.GetBoundingRectangle()).Where(x => x.HasValue).Select(x => x!.Value).ToList();
387387
if (bboxes.Count == 0)
388388
{
389389
return null;
@@ -433,7 +433,7 @@ public void WriteSvg(StringBuilder builder, double height)
433433
}
434434

435435
/// <inheritdoc />
436-
public override bool Equals(object obj)
436+
public override bool Equals(object? obj)
437437
{
438438
return (obj is Close);
439439
}
@@ -479,7 +479,7 @@ public void WriteSvg(StringBuilder builder, double height)
479479
}
480480

481481
/// <inheritdoc />
482-
public override bool Equals(object obj)
482+
public override bool Equals(object? obj)
483483
{
484484
if (obj is Move move)
485485
{
@@ -545,7 +545,7 @@ public void WriteSvg(StringBuilder builder, double height)
545545
}
546546

547547
/// <inheritdoc />
548-
public override bool Equals(object obj)
548+
public override bool Equals(object? obj)
549549
{
550550
if (obj is Line line)
551551
{
@@ -651,7 +651,7 @@ public override IReadOnlyList<Line> ToLines(int n)
651651
}
652652

653653
/// <inheritdoc />
654-
public override bool Equals(object obj)
654+
public override bool Equals(object? obj)
655655
{
656656
if (obj is QuadraticBezierCurve curve)
657657
{
@@ -809,7 +809,7 @@ public override IReadOnlyList<Line> ToLines(int n)
809809
}
810810

811811
/// <inheritdoc />
812-
public override bool Equals(object obj)
812+
public override bool Equals(object? obj)
813813
{
814814
if (obj is CubicBezierCurve curve)
815815
{
@@ -944,7 +944,7 @@ public static double ValueWithT(double p1, double p2, double p3, double p4, doub
944944
/// <summary>
945945
/// Compares two <see cref="PdfSubpath"/>s for equality. Paths will only be considered equal if the commands which construct the paths are in the same order.
946946
/// </summary>
947-
public override bool Equals(object obj)
947+
public override bool Equals(object? obj)
948948
{
949949
if (!(obj is PdfSubpath path) || Commands.Count != path.Commands.Count)
950950
{

src/UglyToad.PdfPig.Core/TransformationMatrix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ internal double GetScalingFactorX()
463463
}
464464

465465
/// <inheritdoc />
466-
public override bool Equals(object obj)
466+
public override bool Equals(object? obj)
467467
{
468468
return obj is TransformationMatrix other && Equals(other);
469469
}

src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<SignAssembly>true</SignAssembly>
99
<AssemblyOriginatorKeyFile>..\pdfpig.snk</AssemblyOriginatorKeyFile>
10+
<Nullable>enable</Nullable>
11+
<WarningsAsErrors>nullable</WarningsAsErrors>
1012
</PropertyGroup>
1113
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
1214
<PackageReference Include="System.ValueTuple" Version="4.5.0" />

0 commit comments

Comments
 (0)