Browse Source

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

pull/17561/head
liangshiwei 3 years ago
parent
commit
37ecd32d22
  1. 2
      framework/src/Volo.Abp.Imaging.Abstractions/Volo.Abp.Imaging.Abstractions.csproj
  2. 4
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressor.cs
  3. 4
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressorContributor.cs
  4. 4
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizer.cs
  5. 4
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizerContributor.cs
  6. 4
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs
  7. 4
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs
  8. 2
      framework/src/Volo.Abp.Imaging.AspNetCore/Volo.Abp.Imaging.AspNetCore.csproj
  9. 2
      framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/CompressImageAttribute.cs
  10. 2
      framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/ResizeImageAttribute.cs
  11. 2
      framework/src/Volo.Abp.Imaging.ImageSharp/Volo.Abp.Imaging.ImageSharp.csproj
  12. 6
      framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageCompressorContributor.cs
  13. 6
      framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageResizerContributor.cs
  14. 2
      framework/src/Volo.Abp.Imaging.MagickNet/Volo.Abp.Imaging.MagickNet.csproj
  15. 6
      framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageCompressorContributor.cs
  16. 6
      framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageResizerContributor.cs

2
framework/src/Volo.Abp.Imaging.Abstractions/Volo.Abp.Imaging.Abstractions.csproj

@ -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>

4
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressor.cs

@ -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
);
}

4
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressorContributor.cs

@ -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);
}

4
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizer.cs

@ -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
);
}

4
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizerContributor.cs

@ -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);
}

4
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs

@ -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));

4
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs

@ -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));

2
framework/src/Volo.Abp.Imaging.AspNetCore/Volo.Abp.Imaging.AspNetCore.csproj

@ -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>

2
framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/CompressImageAttribute.cs

@ -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),

2
framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/ResizeImageAttribute.cs

@ -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),

2
framework/src/Volo.Abp.Imaging.ImageSharp/Volo.Abp.Imaging.ImageSharp.csproj

@ -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>

6
framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageCompressorContributor.cs

@ -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,

6
framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageResizerContributor.cs

@ -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,

2
framework/src/Volo.Abp.Imaging.MagickNet/Volo.Abp.Imaging.MagickNet.csproj

@ -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>

6
framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageCompressorContributor.cs

@ -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,

6
framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageResizerContributor.cs

@ -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