From 4a831f006a73120527e95de386c7e83d73a5586b Mon Sep 17 00:00:00 2001 From: Meee Date: Fri, 24 Mar 2023 14:58:58 +0700 Subject: [PATCH 1/2] Updated exception message and release notes --- .../IronSoftware.Drawing.Common/AnyBitmap.cs | 90 +++++++++---------- NuGet/IronSoftware.Drawing.nuspec | 3 +- 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs b/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs index 3a7343c..b6dd2a9 100644 --- a/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs +++ b/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs @@ -42,7 +42,7 @@ public int Width } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -60,7 +60,7 @@ public int Height } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -128,7 +128,7 @@ public AnyBitmap Clone() } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -153,7 +153,7 @@ public AnyBitmap Clone(CropRectangle Rectangle) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -176,7 +176,7 @@ public byte[] ExportBytes(ImageFormat Format = ImageFormat.Default, int Lossy = } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -202,7 +202,7 @@ public void ExportFile(string File, ImageFormat Format = ImageFormat.Default, in } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -224,7 +224,7 @@ public System.IO.MemoryStream ToStream(ImageFormat Format = ImageFormat.Default, } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -246,7 +246,7 @@ public Func ToStreamFn(ImageFormat Format = ImageFormat.Default, int Los } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -303,7 +303,7 @@ public void ExportStream(System.IO.Stream Stream, ImageFormat Format = ImageForm } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -351,7 +351,7 @@ public bool TrySaveAs(string File, ImageFormat Format, int Lossy = 100) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } catch { @@ -375,7 +375,7 @@ public bool TrySaveAs(string File) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } catch { @@ -437,7 +437,7 @@ public static AnyBitmap FromBytes(byte[] Bytes) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } /// @@ -455,7 +455,7 @@ public AnyBitmap(byte[] Bytes) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -495,7 +495,7 @@ public AnyBitmap(System.IO.MemoryStream Stream) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -513,7 +513,7 @@ public AnyBitmap(System.IO.Stream Stream) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -531,7 +531,7 @@ public AnyBitmap(AnyBitmap original, int width, int height) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -567,7 +567,7 @@ public AnyBitmap(string File) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -648,7 +648,7 @@ public int BitsPerPixel } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -668,7 +668,7 @@ public int FrameCount } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -696,7 +696,7 @@ public IEnumerable GetAllFrames } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } return images; @@ -726,7 +726,7 @@ public static AnyBitmap CreateMultiFrameTiff(IEnumerable imagePaths) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -748,7 +748,7 @@ public static AnyBitmap CreateMultiFrameTiff(IEnumerable images) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -770,7 +770,7 @@ public static AnyBitmap CreateMultiFrameGif(IEnumerable imagePaths) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -792,7 +792,7 @@ public static AnyBitmap CreateMultiFrameGif(IEnumerable images) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -810,7 +810,7 @@ public AnyBitmap RotateFlip(RotateMode rotateMode, FlipMode flipMode) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -829,7 +829,7 @@ public AnyBitmap RotateFlip(RotateFlipType rotateFlipType) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -875,7 +875,7 @@ public static AnyBitmap RotateFlip(AnyBitmap bitmap, RotateMode rotateMode, Flip } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -893,7 +893,7 @@ public AnyBitmap Redact(CropRectangle cropRectangle, Color color) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -923,7 +923,7 @@ public static AnyBitmap Redact(AnyBitmap bitmap, CropRectangle cropRectangle, Co } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -940,7 +940,7 @@ public int Stride } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -959,7 +959,7 @@ public IntPtr Scan0 } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -978,7 +978,7 @@ public string MimeType } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -1004,7 +1004,7 @@ public ImageFormat GetImageFormat() } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -1022,7 +1022,7 @@ public double? HorizontalResolution } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -1041,7 +1041,7 @@ public double? VerticalResolution } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } } @@ -1070,7 +1070,7 @@ public Color GetPixel(int x, int y) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors v2 and v3 you must upgrade to a version of IronSoftware.System.Drawing which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); } } @@ -1097,7 +1097,7 @@ public static implicit operator AnyBitmap(SixLabors.ImageSharp.Image IronSoftware.System.Drawing is an open-source solution for .NET developers to replace System.Drawing.Common with a universal and flexible library. - - Added a deconstructor for the AnyBitmap class to automatically dispose of objects, simplifying memory management. -- Added a new function call to the Color class: ToHtmlCssColorCode(). This translates the specified Color structure to an HTML string color representation. + * Add support message for the new version of SixLabors. Copyright © Iron Software 2022-2023 Images, Bitmap, SkiaSharp, SixLabors, BitMiracle, Maui, SVG, TIFF, TIF, GIF, JPEG, PNG, Color, Rectangle, Drawing, C#, VB.NET, ASPX, create, render, generate, standard, netstandard2.0, core, netcore From e5f666a96ec8c8ddd670f9f16473940932b4631f Mon Sep 17 00:00:00 2001 From: Artem Koloskov <102773427+artem-iron@users.noreply.github.com> Date: Fri, 24 Mar 2023 15:14:38 +0700 Subject: [PATCH 2/2] Update AnyBitmap.cs Use a constant for image sharp missing method exception message --- .../IronSoftware.Drawing.Common/AnyBitmap.cs | 96 ++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs b/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs index b6dd2a9..eef213d 100644 --- a/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs +++ b/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs @@ -24,6 +24,12 @@ namespace IronSoftware.Drawing /// public partial class AnyBitmap : IDisposable { + private const string IMAGE_SHARP_MISSING_METHOD_MESSAGE = + "Due to conflicts between SixLabors.ImageSharp v2 and v3, " + + "to use SixLabors.ImageSharp v3 with Iron Software products " + + "please install IronSoftware.System.Drawing v.2023.4.1-prerelease " + + "NuGet package which supports SixLabors.ImageSharp v3."; + private bool disposed = false; private SixLabors.ImageSharp.Image Image { get; set; } private byte[] Binary { get; set; } @@ -42,7 +48,7 @@ public int Width } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -60,7 +66,7 @@ public int Height } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -128,7 +134,7 @@ public AnyBitmap Clone() } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -153,7 +159,7 @@ public AnyBitmap Clone(CropRectangle Rectangle) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -176,7 +182,7 @@ public byte[] ExportBytes(ImageFormat Format = ImageFormat.Default, int Lossy = } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -202,7 +208,7 @@ public void ExportFile(string File, ImageFormat Format = ImageFormat.Default, in } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -224,7 +230,7 @@ public System.IO.MemoryStream ToStream(ImageFormat Format = ImageFormat.Default, } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -246,7 +252,7 @@ public Func ToStreamFn(ImageFormat Format = ImageFormat.Default, int Los } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -303,7 +309,7 @@ public void ExportStream(System.IO.Stream Stream, ImageFormat Format = ImageForm } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -351,7 +357,7 @@ public bool TrySaveAs(string File, ImageFormat Format, int Lossy = 100) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } catch { @@ -375,7 +381,7 @@ public bool TrySaveAs(string File) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } catch { @@ -437,7 +443,7 @@ public static AnyBitmap FromBytes(byte[] Bytes) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } /// @@ -455,7 +461,7 @@ public AnyBitmap(byte[] Bytes) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -495,7 +501,7 @@ public AnyBitmap(System.IO.MemoryStream Stream) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -513,7 +519,7 @@ public AnyBitmap(System.IO.Stream Stream) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -531,7 +537,7 @@ public AnyBitmap(AnyBitmap original, int width, int height) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -567,7 +573,7 @@ public AnyBitmap(string File) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -648,7 +654,7 @@ public int BitsPerPixel } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -668,7 +674,7 @@ public int FrameCount } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -696,7 +702,7 @@ public IEnumerable GetAllFrames } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } return images; @@ -726,7 +732,7 @@ public static AnyBitmap CreateMultiFrameTiff(IEnumerable imagePaths) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -748,7 +754,7 @@ public static AnyBitmap CreateMultiFrameTiff(IEnumerable images) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -770,7 +776,7 @@ public static AnyBitmap CreateMultiFrameGif(IEnumerable imagePaths) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -792,7 +798,7 @@ public static AnyBitmap CreateMultiFrameGif(IEnumerable images) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -810,7 +816,7 @@ public AnyBitmap RotateFlip(RotateMode rotateMode, FlipMode flipMode) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -829,7 +835,7 @@ public AnyBitmap RotateFlip(RotateFlipType rotateFlipType) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -875,7 +881,7 @@ public static AnyBitmap RotateFlip(AnyBitmap bitmap, RotateMode rotateMode, Flip } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -893,7 +899,7 @@ public AnyBitmap Redact(CropRectangle cropRectangle, Color color) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -923,7 +929,7 @@ public static AnyBitmap Redact(AnyBitmap bitmap, CropRectangle cropRectangle, Co } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -940,7 +946,7 @@ public int Stride } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -959,7 +965,7 @@ public IntPtr Scan0 } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -978,7 +984,7 @@ public string MimeType } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -1004,7 +1010,7 @@ public ImageFormat GetImageFormat() } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -1022,7 +1028,7 @@ public double? HorizontalResolution } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -1041,7 +1047,7 @@ public double? VerticalResolution } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } } @@ -1070,7 +1076,7 @@ public Color GetPixel(int x, int y) } catch (Exception e) when (e is MissingMethodException || e is TypeInitializationException) { - throw new NotSupportedException("Due to conflicts between SixLabors.ImageSharp v2 and v3, to use SixLabors.ImageSharp v3 with Iron Software products please install IronSoftware.System.Drawing v.2023.4.1-prerelease NuGet package which supports SixLabors.ImageSharp v3.", e); + throw new NotSupportedException(IMAGE_SHARP_MISSING_METHOD_MESSAGE, e); } } @@ -1097,7 +1103,7 @@ public static implicit operator AnyBitmap(SixLabors.ImageSharp.Image