From 210945f93909ab903e08456ef51a964841127b43 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Thu, 14 Apr 2022 15:01:54 +0300 Subject: [PATCH] Fixed compilation error for older frameworks --- .../Profiles/Exif/ExifEncodedStringHelpers.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index 6e697029eb..4dc7f83985 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -79,8 +79,20 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif return CharacterCodeBytesLength + count; } - public static unsafe int Write(Encoding encoding, string value, Span destination) => - encoding.GetBytes(value.AsSpan(), destination); + public static unsafe int Write(Encoding encoding, string value, Span destination) +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET + => encoding.GetBytes(value.AsSpan(), destination); +#else + { + fixed (char* c = value) + { + fixed (byte* b = destination) + { + return encoding.GetBytes(c, value.Length, b, destination.Length); + } + } + } +#endif private static bool TryDetect(ReadOnlySpan buffer, out CharacterCode code) {