Enable nullable annotations for Volo.Abp.Imaging.* projets

pull/17561/head
liangshiwei 2 years ago
parent dc448c4b72
commit 37ecd32d22

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<PackageId>Volo.Abp.Imaging.Abstractions</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

@ -9,13 +9,13 @@ public interface IImageCompressor
{
Task<ImageCompressResult<Stream>> CompressAsync(
Stream stream,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default
);
Task<ImageCompressResult<byte[]>> CompressAsync(
byte[] bytes,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default
);
}

@ -9,10 +9,10 @@ public interface IImageCompressorContributor
{
Task<ImageCompressResult<Stream>> TryCompressAsync(
Stream stream,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default);
Task<ImageCompressResult<byte[]>> TryCompressAsync(
byte[] bytes,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default);
}

@ -10,14 +10,14 @@ public interface IImageResizer
Task<ImageResizeResult<Stream>> ResizeAsync(
Stream stream,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default
);
Task<ImageResizeResult<byte[]>> ResizeAsync(
byte[] bytes,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default
);
}

@ -10,12 +10,12 @@ public interface IImageResizerContributor
Task<ImageResizeResult<Stream>> TryResizeAsync(
Stream stream,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default);
Task<ImageResizeResult<byte[]>> TryResizeAsync(
byte[] bytes,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default);
}

@ -23,7 +23,7 @@ public class ImageCompressor : IImageCompressor, ITransientDependency
public virtual async Task<ImageCompressResult<Stream>> CompressAsync(
[NotNull] Stream stream,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(stream, nameof(stream));
@ -45,7 +45,7 @@ public class ImageCompressor : IImageCompressor, ITransientDependency
public virtual async Task<ImageCompressResult<byte[]>> CompressAsync(
[NotNull] byte[] bytes,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(bytes, nameof(bytes));

@ -31,7 +31,7 @@ public class ImageResizer : IImageResizer, ITransientDependency
public virtual async Task<ImageResizeResult<Stream>> ResizeAsync(
[NotNull] Stream stream,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(stream, nameof(stream));
@ -56,7 +56,7 @@ public class ImageResizer : IImageResizer, ITransientDependency
public virtual async Task<ImageResizeResult<byte[]>> ResizeAsync(
[NotNull] byte[] bytes,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(bytes, nameof(bytes));

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<PackageId>Volo.Abp.Imaging.AspNetCore</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

@ -28,7 +28,7 @@ public class CompressImageAttribute : ActionFilterAttribute
foreach (var (key, value) in parameters)
{
object compressedValue = value switch {
object? compressedValue = value switch {
IFormFile file => await CompressImageAsync(file, imageCompressor),
IRemoteStreamContent remoteStreamContent => await CompressImageAsync(remoteStreamContent, imageCompressor),
Stream stream => await CompressImageAsync(stream, imageCompressor),

@ -41,7 +41,7 @@ public class ResizeImageAttribute : ActionFilterAttribute
foreach (var (key, value) in parameters)
{
object resizedValue = value switch {
object? resizedValue = value switch {
IFormFile file => await ResizeImageAsync(file, imageResizer),
IRemoteStreamContent remoteStreamContent => await ResizeImageAsync(remoteStreamContent, imageResizer),
Stream stream => await ResizeImageAsync(stream, imageResizer),

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<PackageId>Volo.Abp.Imaging.ImageSharp</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

@ -26,7 +26,7 @@ public class ImageSharpImageCompressorContributor : IImageCompressorContributor,
public virtual async Task<ImageCompressResult<Stream>> TryCompressAsync(
Stream stream,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType))
@ -54,7 +54,7 @@ public class ImageSharpImageCompressorContributor : IImageCompressorContributor,
public virtual async Task<ImageCompressResult<byte[]>> TryCompressAsync(
byte[] bytes,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType))
@ -75,7 +75,7 @@ public class ImageSharpImageCompressorContributor : IImageCompressorContributor,
return new ImageCompressResult<byte[]>(newBytes, result.State);
}
protected virtual bool CanCompress(string mimeType)
protected virtual bool CanCompress(string? mimeType)
{
return mimeType switch {
MimeTypes.Image.Jpeg => true,

@ -16,7 +16,7 @@ public class ImageSharpImageResizerContributor : IImageResizerContributor, ITran
public virtual async Task<ImageResizeResult<Stream>> TryResizeAsync(
Stream stream,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!string.IsNullOrWhiteSpace(mimeType) && !CanResize(mimeType))
@ -58,7 +58,7 @@ public class ImageSharpImageResizerContributor : IImageResizerContributor, ITran
public virtual async Task<ImageResizeResult<byte[]>> TryResizeAsync(
byte[] bytes,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!string.IsNullOrWhiteSpace(mimeType) && !CanResize(mimeType))
@ -82,7 +82,7 @@ public class ImageSharpImageResizerContributor : IImageResizerContributor, ITran
return new ImageResizeResult<byte[]>(newBytes, result.State);
}
protected virtual bool CanResize(string mimeType)
protected virtual bool CanResize(string? mimeType)
{
return mimeType switch {
MimeTypes.Image.Jpeg => true,

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<PackageId>Volo.Abp.Imaging.MagicNet</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

@ -28,7 +28,7 @@ public class MagickImageCompressorContributor : IImageCompressorContributor, ITr
public virtual async Task<ImageCompressResult<Stream>> TryCompressAsync(
Stream stream,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType))
@ -63,7 +63,7 @@ public class MagickImageCompressorContributor : IImageCompressorContributor, ITr
public virtual async Task<ImageCompressResult<byte[]>> TryCompressAsync(
byte[] bytes,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType))
@ -86,7 +86,7 @@ public class MagickImageCompressorContributor : IImageCompressorContributor, ITr
return new ImageCompressResult<byte[]>(newBytes, result.State);
}
protected virtual bool CanCompress(string mimeType)
protected virtual bool CanCompress(string? mimeType)
{
return mimeType switch {
MimeTypes.Image.Jpeg => true,

@ -16,7 +16,7 @@ public class MagickImageResizerContributor : IImageResizerContributor, ITransien
public virtual async Task<ImageResizeResult<Stream>> TryResizeAsync(
Stream stream,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!mimeType.IsNullOrWhiteSpace() && !CanResize(mimeType))
@ -54,7 +54,7 @@ public class MagickImageResizerContributor : IImageResizerContributor, ITransien
public virtual Task<ImageResizeResult<byte[]>> TryResizeAsync(
byte[] bytes,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
string? mimeType = null,
CancellationToken cancellationToken = default)
{
if (!mimeType.IsNullOrWhiteSpace() && !CanResize(mimeType))
@ -74,7 +74,7 @@ public class MagickImageResizerContributor : IImageResizerContributor, ITransien
return Task.FromResult(new ImageResizeResult<byte[]>(image.ToByteArray(), ImageProcessState.Done));
}
protected virtual bool CanResize(string mimeType)
protected virtual bool CanResize(string? mimeType)
{
return mimeType switch {
MimeTypes.Image.Jpeg => true,

Loading…
Cancel
Save