mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-08-20 09:00:07 +08:00
add nullability to core projec (#1111)
This commit is contained in:
parent
52c0635273
commit
0ebbe0540d
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Buffers;
|
||||||
using System.Buffers;
|
|
||||||
|
|
||||||
namespace UglyToad.PdfPig.Core;
|
namespace UglyToad.PdfPig.Core;
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is IndirectReference other && Equals(other);
|
return obj is IndirectReference other && Equals(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert the string to bytes using the ISO 8859-1 encoding.
|
/// Convert the string to bytes using the ISO 8859-1 encoding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] StringAsLatin1Bytes(string s)
|
public static byte[]? StringAsLatin1Bytes(string? s)
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -264,7 +264,7 @@
|
|||||||
/// Try to convert raw bytes to a PdfDocEncoding encoded string. If unsupported characters are encountered
|
/// 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.
|
/// meaning we cannot safely round-trip the value to bytes this will instead return false.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool TryConvertBytesToString(ReadOnlySpan<byte> bytes, out string result)
|
public static bool TryConvertBytesToString(ReadOnlySpan<byte> bytes, out string? result)
|
||||||
{
|
{
|
||||||
result = null;
|
result = null;
|
||||||
if (bytes.Length == 0)
|
if (bytes.Length == 0)
|
||||||
|
|||||||
@ -70,7 +70,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a value indicating whether this <see cref="PdfLine"/> is equal to a specified <see cref="PdfLine"/> .
|
/// Returns a value indicating whether this <see cref="PdfLine"/> is equal to a specified <see cref="PdfLine"/> .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is PdfLine other && Equals(other);
|
return obj is PdfLine other && Equals(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a value indicating whether this <see cref="PdfPoint"/> is equal to a specified <see cref="PdfPoint"/> .
|
/// Returns a value indicating whether this <see cref="PdfPoint"/> is equal to a specified <see cref="PdfPoint"/> .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is PdfPoint other && Equals(other);
|
return obj is PdfPoint other && Equals(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -177,7 +177,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is PdfRectangle other && Equals(other);
|
return obj is PdfRectangle other && Equals(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -241,8 +241,8 @@
|
|||||||
public bool IsClosed()
|
public bool IsClosed()
|
||||||
{
|
{
|
||||||
var filteredCount = 0;
|
var filteredCount = 0;
|
||||||
IPathCommand last = null;
|
IPathCommand? last = null;
|
||||||
IPathCommand first = null;
|
IPathCommand? first = null;
|
||||||
for (int i = Commands.Count - 1; i >= 0; i--)
|
for (int i = Commands.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var cmd = Commands[i];
|
var cmd = Commands[i];
|
||||||
@ -376,14 +376,14 @@
|
|||||||
/// Gets a <see cref="PdfRectangle"/> which entirely contains the geometry of the defined path.
|
/// Gets a <see cref="PdfRectangle"/> which entirely contains the geometry of the defined path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>For paths which don't define any geometry this returns <see langword="null"/>.</returns>
|
/// <returns>For paths which don't define any geometry this returns <see langword="null"/>.</returns>
|
||||||
public static PdfRectangle? GetBoundingRectangle(IReadOnlyList<PdfSubpath> path)
|
public static PdfRectangle? GetBoundingRectangle(IReadOnlyList<PdfSubpath>? path)
|
||||||
{
|
{
|
||||||
if (path == null || path.Count == 0)
|
if (path == null || path.Count == 0)
|
||||||
{
|
{
|
||||||
return null;
|
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)
|
if (bboxes.Count == 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -433,7 +433,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return (obj is Close);
|
return (obj is Close);
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
if (obj is Move move)
|
if (obj is Move move)
|
||||||
{
|
{
|
||||||
@ -545,7 +545,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
if (obj is Line line)
|
if (obj is Line line)
|
||||||
{
|
{
|
||||||
@ -651,7 +651,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
if (obj is QuadraticBezierCurve curve)
|
if (obj is QuadraticBezierCurve curve)
|
||||||
{
|
{
|
||||||
@ -809,7 +809,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
if (obj is CubicBezierCurve curve)
|
if (obj is CubicBezierCurve curve)
|
||||||
{
|
{
|
||||||
@ -944,7 +944,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
if (!(obj is PdfSubpath path) || Commands.Count != path.Commands.Count)
|
if (!(obj is PdfSubpath path) || Commands.Count != path.Commands.Count)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -463,7 +463,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is TransformationMatrix other && Equals(other);
|
return obj is TransformationMatrix other && Equals(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>..\pdfpig.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>..\pdfpig.snk</AssemblyOriginatorKeyFile>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<WarningsAsErrors>nullable</WarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
|
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
|
|||||||
@ -89,7 +89,7 @@ namespace UglyToad.PdfPig.Core
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool TryGetSecond(out B b)
|
public override bool TryGetSecond(out B b)
|
||||||
{
|
{
|
||||||
b = default(B);
|
b = default!;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ namespace UglyToad.PdfPig.Core
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool TryGetFirst(out A a)
|
public override bool TryGetFirst(out A a)
|
||||||
{
|
{
|
||||||
a = default(A);
|
a = default!;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user