Browse Source

Change Guard

removed the generic constrained of IResampler and added notnull
pull/2353/head
Stefan Nikolei 4 years ago
parent
commit
0e40d71895
  1. 5
      src/ImageSharp/Common/Helpers/Guard.cs
  2. 2
      src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor.cs
  3. 2
      src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor.cs
  4. 2
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs

5
src/ImageSharp/Common/Helpers/Guard.cs

@ -3,7 +3,6 @@
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing.Processors.Transforms;
namespace SixLabors;
@ -17,8 +16,8 @@ internal static partial class Guard
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <exception cref="ArgumentException"><paramref name="value"/> is not a value type.</exception>
[MethodImpl(InliningOptions.ShortMethod)]
public static void SamplerMustBeValueType<TValue>(TValue value, [CallerArgumentExpression("value")] string? parameterName = null)
where TValue : IResampler
public static void MustBeValueType<TValue>(TValue value, [CallerArgumentExpression("value")] string? parameterName = null)
where TValue : notnull
{
if (value.GetType().IsValueType)
{

2
src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor.cs

@ -19,7 +19,7 @@ public class AffineTransformProcessor : CloningImageProcessor
public AffineTransformProcessor(Matrix3x2 matrix, IResampler sampler, Size targetDimensions)
{
Guard.NotNull(sampler, nameof(sampler));
Guard.SamplerMustBeValueType(sampler);
Guard.MustBeValueType(sampler);
if (TransformUtils.IsDegenerate(matrix))
{

2
src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor.cs

@ -19,7 +19,7 @@ public sealed class ProjectiveTransformProcessor : CloningImageProcessor
public ProjectiveTransformProcessor(Matrix4x4 matrix, IResampler sampler, Size targetDimensions)
{
Guard.NotNull(sampler, nameof(sampler));
Guard.SamplerMustBeValueType(sampler);
Guard.MustBeValueType(sampler);
if (TransformUtils.IsDegenerate(matrix))
{

2
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs

@ -17,7 +17,7 @@ public class ResizeProcessor : CloningImageProcessor
{
Guard.NotNull(options, nameof(options));
Guard.NotNull(options.Sampler, nameof(options.Sampler));
Guard.SamplerMustBeValueType(options.Sampler);
Guard.MustBeValueType(options.Sampler);
(Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds(sourceSize, options);

Loading…
Cancel
Save