Skip to content

Enable Nullable ReferenceTypes #2236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
c4eac9a
Enable Nullable analysis
stefannikolei Sep 18, 2022
eca1842
disable nullable for AotCompilerTools
stefannikolei Sep 18, 2022
a6b2994
Fix NRT for Equals
stefannikolei Sep 18, 2022
5c72765
Fix Nrt for Guard
stefannikolei Sep 18, 2022
823c3ac
Fix NRT for ColorSpaceConverter
stefannikolei Sep 18, 2022
c79cfde
NRT Deflate
stefannikolei Sep 18, 2022
38ffa32
NRT Zlib
stefannikolei Sep 18, 2022
ca97383
NRT Diagnostics
stefannikolei Sep 18, 2022
843efd6
NRT Formats.Bmp
stefannikolei Sep 18, 2022
0c24bcb
NRT Formats.Gif
stefannikolei Sep 18, 2022
c66abc2
Nrt format jpeg
stefannikolei Sep 18, 2022
007c181
Nrt Format Jpeg
stefannikolei Sep 18, 2022
f5ecb0d
NRT Formats.Pbm
stefannikolei Sep 18, 2022
5c3b9be
NRT Formats.Png
stefannikolei Sep 18, 2022
a826358
NRT Formats.Tga
stefannikolei Sep 18, 2022
d4298dd
NRT Formats.Tiff
stefannikolei Sep 18, 2022
a77d8cb
NRT Formats.Webp
stefannikolei Sep 19, 2022
9979a45
NRT IO
stefannikolei Sep 19, 2022
7e34020
NRT Memory
stefannikolei Sep 19, 2022
d9b1195
NRT Metadata.Profiles.Exif
stefannikolei Sep 19, 2022
e3d0f55
NRT Profiles.ICC
stefannikolei Sep 19, 2022
3d64071
NRT Profiles.IPTC
stefannikolei Sep 20, 2022
fd959bf
NRT Profiles.XMP
stefannikolei Sep 20, 2022
72902e2
NRT PixelFormats
stefannikolei Sep 20, 2022
850973a
NRT Formats
stefannikolei Sep 20, 2022
bc9e844
NRT Processors
stefannikolei Sep 20, 2022
f211e22
NRT root
stefannikolei Sep 20, 2022
c0d1a02
Remove generic constraint for struct
stefannikolei Sep 20, 2022
b4b06cb
Fix tests
stefannikolei Sep 20, 2022
fc3dcf6
NRT PixelBuffer
stefannikolei Sep 20, 2022
64ca55a
Fix build
stefannikolei Sep 20, 2022
81382d6
Update shared-infrastructure
stefannikolei Sep 20, 2022
e847261
Set UTF8 as standard encoding in IptcValue
stefannikolei Sep 20, 2022
afd0d94
Refactor
stefannikolei Sep 20, 2022
9efb6fa
Refactor TgaDecoderCore
stefannikolei Sep 20, 2022
a2d3107
Refactor GifDecoderCore
stefannikolei Sep 20, 2022
eb6eb27
Ref HuffmanScanDecoder
stefannikolei Sep 20, 2022
e32f9a7
Ref JpegDecoderCore
stefannikolei Sep 20, 2022
2371ade
Ref TgaDecoderCore
stefannikolei Sep 20, 2022
72b4104
Ref TgaEncoderCore
stefannikolei Sep 20, 2022
e069144
Ref PngEncoderCore
stefannikolei Sep 20, 2022
7b08973
Ref PngDecoderCore
stefannikolei Sep 21, 2022
bce687b
Ref TiffDecoderCore
stefannikolei Sep 21, 2022
ccceb94
Ref PngEncoder
stefannikolei Sep 21, 2022
e5af3a6
Ref DeflaterEngine
stefannikolei Sep 21, 2022
12a62b7
Ref WebpEncoderCore
stefannikolei Sep 21, 2022
5372ac0
Ref JpegFrame
stefannikolei Sep 21, 2022
c56fc3c
Ref JpegEncoderCore
stefannikolei Sep 21, 2022
6213cb2
Ref ArithmeticScanDecoder
stefannikolei Sep 21, 2022
3973224
Ref LzwCompressor
stefannikolei Sep 21, 2022
3164d1e
Ref PackBitsCompressor
stefannikolei Sep 21, 2022
326d34c
Ref T6BitCompressor
stefannikolei Sep 21, 2022
5620ff0
REf TiffCcittCompressor
stefannikolei Sep 21, 2022
1d946bd
Ref PackBitsTiffCompression
stefannikolei Sep 21, 2022
d12b07c
Ref TiffEncoderCore
stefannikolei Sep 21, 2022
1dd9eec
Ref TiffBiColorWriter
stefannikolei Sep 21, 2022
47872a2
Ref TiffPaletteWriter
stefannikolei Sep 21, 2022
dc51d9e
Ref TiffCompositeColorWriter
stefannikolei Sep 21, 2022
17bf4bb
Ref Vp8BitWriter
stefannikolei Sep 21, 2022
7fd533f
Ref ColorCache
stefannikolei Sep 21, 2022
a3df5cf
Ref Vp8LDecoder
stefannikolei Sep 21, 2022
b380a8a
Ref Vp8LEncodeer
stefannikolei Sep 21, 2022
1c868cc
Ref Vp8LTransform
stefannikolei Sep 21, 2022
2885487
Ref Vp8Decoder
stefannikolei Sep 21, 2022
f80cc18
Ref Vp8Decoder
stefannikolei Sep 21, 2022
d3891c0
Ref SpectralConverter
stefannikolei Sep 21, 2022
da8d1d5
Cleanup
stefannikolei Sep 21, 2022
b08a192
Update shared infrastructure
stefannikolei Sep 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions src/ImageSharp/Advanced/AdvancedImageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static IImageEncoder DetectEncoder(this Image source, string filePath)
Guard.NotNull(filePath, nameof(filePath));

string ext = Path.GetExtension(filePath);
IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
IImageFormat? format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
if (format is null)
{
StringBuilder sb = new();
Expand All @@ -40,7 +40,7 @@ public static IImageEncoder DetectEncoder(this Image source, string filePath)
throw new NotSupportedException(sb.ToString());
}

IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format);
IImageEncoder? encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format);

if (encoder is null)
{
Expand Down Expand Up @@ -99,7 +99,7 @@ public static Configuration GetConfiguration(this ImageFrame source)
/// <param name="source">The source image</param>
/// <returns>Returns the bounds of the image</returns>
private static Configuration GetConfiguration(IConfigurationProvider source)
=> source?.Configuration ?? Configuration.Default;
=> source.Configuration ?? Configuration.Default;

/// <summary>
/// Gets the representation of the pixels as a <see cref="IMemoryGroup{T}"/> containing the backing pixel data of the image
Expand All @@ -115,7 +115,7 @@ private static Configuration GetConfiguration(IConfigurationProvider source)
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="source"/> in <see langword="null"/>.</exception>
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<TPixel> source)
where TPixel : unmanaged, IPixel<TPixel>
=> source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
=> source.PixelBuffer!.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));

/// <summary>
/// Gets the representation of the pixels as a <see cref="IMemoryGroup{T}"/> containing the backing pixel data of the image
Expand All @@ -131,7 +131,7 @@ public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<T
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="source"/> in <see langword="null"/>.</exception>
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this Image<TPixel> source)
where TPixel : unmanaged, IPixel<TPixel>
=> source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
=> source.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));

/// <summary>
/// Gets the representation of the pixels as a <see cref="Span{T}"/> of contiguous memory
Expand All @@ -148,7 +148,7 @@ public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this ImageFrame<
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
Guard.MustBeLessThan(rowIndex, source.Height, nameof(rowIndex));

return source.PixelBuffer.GetSafeRowMemory(rowIndex);
return source.PixelBuffer!.GetSafeRowMemory(rowIndex);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JimBobSquarePants Should I look for all places where I used ! and add an ArgumentNullException.ThrowIfNull?

}

/// <summary>
Expand All @@ -166,7 +166,7 @@ public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this Image<TPixe
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
Guard.MustBeLessThan(rowIndex, source.Height, nameof(rowIndex));

return source.Frames.RootFrame.PixelBuffer.GetSafeRowMemory(rowIndex);
return source.Frames.RootFrame.PixelBuffer!.GetSafeRowMemory(rowIndex);
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/ImageSharp/Advanced/AotCompilerTools.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

#nullable disable
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Advanced/IConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ internal interface IConfigurationProvider
/// <summary>
/// Gets the configuration which allows altering default behaviour or extending the library.
/// </summary>
Configuration Configuration { get; }
Configuration? Configuration { get; }
}
2 changes: 1 addition & 1 deletion src/ImageSharp/Advanced/IPixelSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ internal interface IPixelSource<TPixel>
/// <summary>
/// Gets the pixel buffer.
/// </summary>
Buffer2D<TPixel> PixelBuffer { get; }
Buffer2D<TPixel>? PixelBuffer { get; }
}
4 changes: 2 additions & 2 deletions src/ImageSharp/Color/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp;
public readonly partial struct Color : IEquatable<Color>
{
private readonly Rgba64 data;
private readonly IPixel boxedHighPrecisionPixel;
private readonly IPixel? boxedHighPrecisionPixel;

[MethodImpl(InliningOptions.ShortMethod)]
private Color(byte r, byte g, byte b, byte a)
Expand Down Expand Up @@ -316,7 +316,7 @@ public bool Equals(Color other)
}

/// <inheritdoc />
public override bool Equals(object obj) => obj is Color other && this.Equals(other);
public override bool Equals(object? obj) => obj is Color other && this.Equals(other);

/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/CieLab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public CieLab(Vector3 vector, CieXyz whitePoint)
public override string ToString() => FormattableString.Invariant($"CieLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLab other && this.Equals(other);
public override bool Equals(object? obj) => obj is CieLab other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/CieLch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public override int GetHashCode()

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public override bool Equals(object obj) => obj is CieLch other && this.Equals(other);
public override bool Equals(object? obj) => obj is CieLch other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/CieLchuv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public CieLchuv(Vector3 vector, CieXyz whitePoint)
public override string ToString() => FormattableString.Invariant($"CieLchuv({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLchuv other && this.Equals(other);
public override bool Equals(object? obj) => obj is CieLchuv other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/CieLuv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public CieLuv(Vector3 vector, CieXyz whitePoint)
public override string ToString() => FormattableString.Invariant($"CieLuv({this.L:#0.##}, {this.U:#0.##}, {this.V:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLuv other && this.Equals(other);
public override bool Equals(object? obj) => obj is CieLuv other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/CieXyy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public CieXyy(Vector3 vector)
public override string ToString() => FormattableString.Invariant($"CieXyy({this.X:#0.##}, {this.Y:#0.##}, {this.Yl:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyy other && this.Equals(other);
public override bool Equals(object? obj) => obj is CieXyy other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/CieXyz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public CieXyz(Vector3 vector)
public override string ToString() => FormattableString.Invariant($"CieXyz({this.X:#0.##}, {this.Y:#0.##}, {this.Z:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyz other && this.Equals(other);
public override bool Equals(object? obj) => obj is CieXyz other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Cmyk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Cmyk(Vector4 vector)
public override string ToString() => FormattableString.Invariant($"Cmyk({this.C:#0.##}, {this.M:#0.##}, {this.Y:#0.##}, {this.K:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is Cmyk other && this.Equals(other);
public override bool Equals(object? obj) => obj is Cmyk other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public CieXyz Adapt(in CieXyz color, in CieXyz sourceWhitePoint, in CieXyz targe
return color;
}

return this.chromaticAdaptation.Transform(color, sourceWhitePoint, targetWhitePoint);
return this.chromaticAdaptation!.Transform(color, sourceWhitePoint, targetWhitePoint);
}

/// <summary>
Expand Down Expand Up @@ -132,7 +132,7 @@ public LinearRgb Adapt(in LinearRgb color)
CieXyz unadapted = converterToXYZ.Convert(color);

// Adaptation
CieXyz adapted = this.chromaticAdaptation.Transform(unadapted, color.WorkingSpace.WhitePoint, this.targetRgbWorkingSpace.WhitePoint);
CieXyz adapted = this.chromaticAdaptation!.Transform(unadapted, color.WorkingSpace.WhitePoint, this.targetRgbWorkingSpace.WhitePoint);

// Conversion back to RGB
return this.cieXyzToLinearRgbConverter.Convert(adapted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class ColorSpaceConverter
{
private static readonly HunterLabToCieXyzConverter HunterLabToCieXyzConverter = new();

private LinearRgbToCieXyzConverter linearRgbToCieXyzConverter;
private LinearRgbToCieXyzConverter? linearRgbToCieXyzConverter;

/// <summary>
/// Converts a <see cref="CieLab"/> into a <see cref="CieXyz"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class ColorSpaceConverter
private readonly CieXyz targetLabWhitePoint;
private readonly CieXyz targetHunterLabWhitePoint;
private readonly RgbWorkingSpace targetRgbWorkingSpace;
private readonly IChromaticAdaptation chromaticAdaptation;
private readonly IChromaticAdaptation? chromaticAdaptation;
private readonly bool performChromaticAdaptation;
private readonly CieXyzAndLmsConverter cieXyzAndLmsConverter;
private readonly CieXyzToCieLabConverter cieXyzToCieLabConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override string ToString()
=> FormattableString.Invariant($"CieXyChromaticityCoordinates({this.X:#0.##}, {this.Y:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj)
public override bool Equals(object? obj)
=> obj is CieXyChromaticityCoordinates other && this.Equals(other);

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public RgbPrimariesChromaticityCoordinates(CieXyChromaticityCoordinates r, CieXy
}

/// <inheritdoc/>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is RgbPrimariesChromaticityCoordinates other && this.Equals(other);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public GammaWorkingSpace(float gamma, CieXyz referenceWhite, RgbPrimariesChromat
public override float Expand(float channel) => GammaCompanding.Expand(channel, this.Gamma);

/// <inheritdoc/>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected RgbWorkingSpace(CieXyz referenceWhite, RgbPrimariesChromaticityCoordin
public abstract float Compress(float channel);

/// <inheritdoc/>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Hsl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Hsl(Vector3 vector)
public override string ToString() => FormattableString.Invariant($"Hsl({this.H:#0.##}, {this.S:#0.##}, {this.L:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsl other && this.Equals(other);
public override bool Equals(object? obj) => obj is Hsl other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Hsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Hsv(Vector3 vector)
public override string ToString() => FormattableString.Invariant($"Hsv({this.H:#0.##}, {this.S:#0.##}, {this.V:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsv other && this.Equals(other);
public override bool Equals(object? obj) => obj is Hsv other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/HunterLab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public HunterLab(Vector3 vector, CieXyz whitePoint)
public override string ToString() => FormattableString.Invariant($"HunterLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is HunterLab other && this.Equals(other);
public override bool Equals(object? obj) => obj is HunterLab other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/LinearRgb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public LinearRgb(Vector3 vector, RgbWorkingSpace workingSpace)
public override string ToString() => FormattableString.Invariant($"LinearRgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is LinearRgb other && this.Equals(other);
public override bool Equals(object? obj) => obj is LinearRgb other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Lms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Lms(Vector3 vector)
public override string ToString() => FormattableString.Invariant($"Lms({this.L:#0.##}, {this.M:#0.##}, {this.S:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is Lms other && this.Equals(other);
public override bool Equals(object? obj) => obj is Lms other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Rgb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public Rgb(Vector3 vector, RgbWorkingSpace workingSpace)
public override string ToString() => FormattableString.Invariant($"Rgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is Rgb other && this.Equals(other);
public override bool Equals(object? obj) => obj is Rgb other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/YCbCr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public YCbCr(Vector3 vector)
public override string ToString() => FormattableString.Invariant($"YCbCr({this.Y}, {this.Cb}, {this.Cr})");

/// <inheritdoc/>
public override bool Equals(object obj) => obj is YCbCr other && this.Equals(other);
public override bool Equals(object? obj) => obj is YCbCr other && this.Equals(other);

/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
Expand Down
1 change: 1 addition & 0 deletions src/ImageSharp/Common/Helpers/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal static partial class Guard
/// <exception cref="ArgumentException"><paramref name="value"/> is not a value type.</exception>
[MethodImpl(InliningOptions.ShortMethod)]
public static void MustBeValueType<TValue>(TValue value, string parameterName)
where TValue : class
{
if (value.GetType().IsValueType)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Common/Helpers/UnitConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal static class UnitConverter
[MethodImpl(InliningOptions.ShortMethod)]
public static PixelResolutionUnit ExifProfileToResolutionUnit(ExifProfile profile)
{
IExifValue<ushort> resolution = profile.GetValue(ExifTag.ResolutionUnit);
IExifValue<ushort>? resolution = profile.GetValue(ExifTag.ResolutionUnit);

// EXIF is 1, 2, 3 so we minus "1" off the result.
return resolution is null ? DefaultResolutionUnit : (PixelResolutionUnit)(byte)(resolution.Value - 1);
Expand Down
1 change: 0 additions & 1 deletion src/ImageSharp/Compression/Zlib/Deflater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ public void Dispose()
if (!this.isDisposed)
{
this.engine.Dispose();
this.engine = null;
this.isDisposed = true;
}
}
Expand Down
18 changes: 6 additions & 12 deletions src/ImageSharp/Compression/Zlib/DeflaterEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable
/// <summary>
/// The input data for compression.
/// </summary>
private byte[] inputBuf;
private byte[]? inputBuf;

/// <summary>
/// The offset into inputBuf, where input data starts.
Expand Down Expand Up @@ -221,12 +221,9 @@ public bool Deflate(bool flush, bool finish)
/// <param name="buffer">The buffer containing input data.</param>
/// <param name="offset">The offset of the first byte of data.</param>
/// <param name="count">The number of bytes of data to use as input.</param>
public void SetInput(byte[] buffer, int offset, int count)
public void SetInput(byte[]? buffer, int offset, int count)
{
if (buffer is null)
{
DeflateThrowHelper.ThrowNull(nameof(buffer));
}
ArgumentNullException.ThrowIfNull(buffer);

if (offset < 0)
{
Expand Down Expand Up @@ -342,7 +339,7 @@ public void SetLevel(int level)
/// <summary>
/// Fill the window
/// </summary>
public void FillWindow()
private void FillWindow()
{
// If the window is almost full and there is insufficient lookahead,
// move the upper half to the lower one to make room in the upper half.
Expand All @@ -361,6 +358,8 @@ public void FillWindow()
more = this.inputEnd - this.inputOff;
}

ArgumentNullException.ThrowIfNull(this.inputBuf);

Unsafe.CopyBlockUnaligned(
ref this.window.Span[this.strstart + this.lookahead],
ref this.inputBuf[this.inputOff],
Expand Down Expand Up @@ -392,11 +391,6 @@ public void Dispose()
this.prevMemoryHandle.Dispose();
this.prevMemoryOwner.Dispose();

this.windowMemoryOwner = null;
this.headMemoryOwner = null;
this.prevMemoryOwner = null;
this.huffman = null;

this.isDisposed = true;
}
}
Expand Down
Loading