Browse Source

Drop netstandard1.1 support

pull/737/head
Jason Nelson 8 years ago
parent
commit
56d351058f
  1. 4
      src/ImageSharp/Common/Extensions/EncoderExtensions.cs
  2. 4
      src/ImageSharp/Common/Helpers/TestHelpers.cs
  3. 8
      src/ImageSharp/Configuration.cs
  4. 2
      src/ImageSharp/IO/IFileSystem.cs
  5. 17
      src/ImageSharp/IO/LocalFileSystem.cs
  6. 3
      src/ImageSharp/Image.FromBytes.cs
  7. 4
      src/ImageSharp/Image.FromFile.cs
  8. 3
      src/ImageSharp/ImageExtensions.cs
  9. 4
      src/ImageSharp/ImageSharp.csproj
  10. 9
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  11. 5
      src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs
  12. 5
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs
  13. 26
      tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs

4
src/ImageSharp/Common/Extensions/EncoderExtensions.cs

@ -20,14 +20,10 @@ namespace SixLabors.ImageSharp
/// <returns>The string.</returns> /// <returns>The string.</returns>
public static string GetString(this Encoding encoding, ReadOnlySpan<byte> buffer) public static string GetString(this Encoding encoding, ReadOnlySpan<byte> buffer)
{ {
#if NETSTANDARD1_1
return encoding.GetString(buffer.ToArray());
#else
fixed (byte* bytes = buffer) fixed (byte* bytes = buffer)
{ {
return encoding.GetString(bytes, buffer.Length); return encoding.GetString(bytes, buffer.Length);
} }
#endif
} }
} }
} }

4
src/ImageSharp/Common/Helpers/TestHelpers.cs

@ -13,9 +13,7 @@ namespace SixLabors.ImageSharp.Common.Helpers
/// Only intended to be used in tests! /// Only intended to be used in tests!
/// </summary> /// </summary>
internal const string ImageSharpBuiltAgainst = internal const string ImageSharpBuiltAgainst =
#if NETSTANDARD1_1 #if NETCOREAPP2_1
"netstandard1.1";
#elif NETCOREAPP2_1
"netcoreapp2.1"; "netcoreapp2.1";
#else #else
"netstandard2.0"; "netstandard2.0";

8
src/ImageSharp/Configuration.cs

@ -3,15 +3,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png;
#if !NETSTANDARD1_1
using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.IO;
#endif
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.Memory; using SixLabors.Memory;
@ -100,12 +97,10 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
internal int MaxHeaderSize => this.ImageFormatsManager.MaxHeaderSize; internal int MaxHeaderSize => this.ImageFormatsManager.MaxHeaderSize;
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// Gets or sets the filesystem helper for accessing the local file system. /// Gets or sets the filesystem helper for accessing the local file system.
/// </summary> /// </summary>
internal IFileSystem FileSystem { get; set; } = new LocalFileSystem(); internal IFileSystem FileSystem { get; set; } = new LocalFileSystem();
#endif
/// <summary> /// <summary>
/// Gets or sets the image operations provider factory. /// Gets or sets the image operations provider factory.
@ -135,10 +130,7 @@ namespace SixLabors.ImageSharp
MemoryAllocator = this.MemoryAllocator, MemoryAllocator = this.MemoryAllocator,
ImageOperationsProvider = this.ImageOperationsProvider, ImageOperationsProvider = this.ImageOperationsProvider,
ReadOrigin = this.ReadOrigin, ReadOrigin = this.ReadOrigin,
#if !NETSTANDARD1_1
FileSystem = this.FileSystem FileSystem = this.FileSystem
#endif
}; };
} }

2
src/ImageSharp/IO/IFileSystem.cs

@ -5,7 +5,6 @@ using System.IO;
namespace SixLabors.ImageSharp.IO namespace SixLabors.ImageSharp.IO
{ {
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// A simple interface representing the filesystem. /// A simple interface representing the filesystem.
/// </summary> /// </summary>
@ -25,5 +24,4 @@ namespace SixLabors.ImageSharp.IO
/// <returns>A stream representing the file to open.</returns> /// <returns>A stream representing the file to open.</returns>
Stream Create(string path); Stream Create(string path);
} }
#endif
} }

17
src/ImageSharp/IO/LocalFileSystem.cs

@ -1,30 +1,19 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
namespace SixLabors.ImageSharp.IO namespace SixLabors.ImageSharp.IO
{ {
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// A wrapper around the local File apis. /// A wrapper around the local File apis.
/// </summary> /// </summary>
internal class LocalFileSystem : IFileSystem internal class LocalFileSystem : IFileSystem
{ {
/// <inheritdoc/> /// <inheritdoc/>
public Stream OpenRead(string path) public Stream OpenRead(string path) => File.OpenRead(path);
{
return File.OpenRead(path);
}
/// <inheritdoc/> /// <inheritdoc/>
public Stream Create(string path) public Stream Create(string path) => File.Create(path);
{
return File.Create(path);
}
} }
#endif }
}

3
src/ImageSharp/Image.FromBytes.cs

@ -174,8 +174,6 @@ namespace SixLabors.ImageSharp
} }
} }
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// By reading the header on the provided byte array this calculates the images format. /// By reading the header on the provided byte array this calculates the images format.
/// </summary> /// </summary>
@ -303,6 +301,5 @@ namespace SixLabors.ImageSharp
} }
} }
} }
#endif
} }
} }

4
src/ImageSharp/Image.FromFile.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
#if !NETSTANDARD1_1
using System; using System;
using System.IO; using System.IO;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
@ -212,5 +211,4 @@ namespace SixLabors.ImageSharp
} }
} }
} }
} }
#endif

3
src/ImageSharp/ImageExtensions.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
@ -17,7 +16,6 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
public static partial class ImageExtensions public static partial class ImageExtensions
{ {
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// Writes the image to the given stream using the currently loaded image format. /// Writes the image to the given stream using the currently loaded image format.
/// </summary> /// </summary>
@ -78,7 +76,6 @@ namespace SixLabors.ImageSharp
source.Save(fs, encoder); source.Save(fs, encoder);
} }
} }
#endif
/// <summary> /// <summary>
/// Writes the image to the given stream using the currently loaded image format. /// Writes the image to the given stream using the currently loaded image format.

4
src/ImageSharp/ImageSharp.csproj

@ -5,7 +5,7 @@
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> <VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix>
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> <VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix>
<Authors>Six Labors and contributors</Authors> <Authors>Six Labors and contributors</Authors>
<TargetFrameworks>netstandard1.1;netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks> <TargetFrameworks>netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>SixLabors.ImageSharp</AssemblyName> <AssemblyName>SixLabors.ImageSharp</AssemblyName>
@ -47,7 +47,7 @@
<PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" /> <PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' OR '$(TargetFramework)' == 'netstandard1.3'"> <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" /> <PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />

9
src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs

@ -3,10 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !NETSTANDARD1_1
using System.Security.Cryptography; using System.Security.Cryptography;
#endif
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
@ -100,8 +97,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public IccProfile DeepClone() => new IccProfile(this); public IccProfile DeepClone() => new IccProfile(this);
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// Calculates the MD5 hash value of an ICC profile /// Calculates the MD5 hash value of an ICC profile
/// </summary> /// </summary>
@ -147,8 +142,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
} }
#endif
/// <summary> /// <summary>
/// Checks for signs of a corrupt profile. /// Checks for signs of a corrupt profile.
/// </summary> /// </summary>
@ -227,4 +220,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
this.entries = new List<IccTagDataEntry>(reader.ReadTagData(this.data)); this.entries = new List<IccTagDataEntry>(reader.ReadTagData(this.data));
} }
} }
} }

5
src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -51,12 +50,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
writer.WriteXyzNumber(header.PcsIlluminant); writer.WriteXyzNumber(header.PcsIlluminant);
writer.WriteAsciiString(header.CreatorSignature, 4, false); writer.WriteAsciiString(header.CreatorSignature, 4, false);
#if !NETSTANDARD1_1
IccProfileId id = IccProfile.CalculateHash(writer.GetData()); IccProfileId id = IccProfile.CalculateHash(writer.GetData());
writer.WriteProfileId(id); writer.WriteProfileId(id);
#else
writer.WriteProfileId(IccProfileId.Zero);
#endif
} }
private void WriteTagTable(IccDataWriter writer, IccTagTableEntry[] table) private void WriteTagTable(IccDataWriter writer, IccTagTableEntry[] table)

5
tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs

@ -9,9 +9,6 @@ namespace SixLabors.ImageSharp.Tests.Icc
{ {
public class IccProfileTests public class IccProfileTests
{ {
#if !NETSTANDARD1_1
[Theory] [Theory]
[MemberData(nameof(IccTestDataProfiles.ProfileIdTestData), MemberType = typeof(IccTestDataProfiles))] [MemberData(nameof(IccTestDataProfiles.ProfileIdTestData), MemberType = typeof(IccTestDataProfiles))]
public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccProfileId expected) public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccProfileId expected)
@ -33,8 +30,6 @@ namespace SixLabors.ImageSharp.Tests.Icc
Assert.Equal(data, copy); Assert.Equal(data, copy);
} }
#endif
[Theory] [Theory]
[MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))]
public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected)

26
tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs

@ -14,20 +14,12 @@ namespace SixLabors.ImageSharp.Tests
public static readonly byte[] Header_Random_Id_Array = public static readonly byte[] Header_Random_Id_Array =
{ {
#if !NETSTANDARD1_1 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38,
0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38,
#else
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#endif
}; };
public static readonly byte[] Profile_Random_Id_Array = public static readonly byte[] Profile_Random_Id_Array =
{ {
#if !NETSTANDARD1_1 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F,
0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F,
#else
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#endif
}; };
public static readonly IccProfileHeader Header_Random_Write = CreateHeaderRandomValue( public static readonly IccProfileHeader Header_Random_Write = CreateHeaderRandomValue(
@ -35,13 +27,7 @@ namespace SixLabors.ImageSharp.Tests
new IccProfileId(1, 2, 3, 4), // should be overwritten new IccProfileId(1, 2, 3, 4), // should be overwritten
"ijkl"); // should be overwritten to "acsp" "ijkl"); // should be overwritten to "acsp"
public static readonly IccProfileHeader Header_Random_Read = CreateHeaderRandomValue(132, public static readonly IccProfileHeader Header_Random_Read = CreateHeaderRandomValue(132, Header_Random_Id_Value, "acsp");
#if !NETSTANDARD1_1
Header_Random_Id_Value,
#else
IccProfileId.Zero,
#endif
"acsp");
public static readonly byte[] Header_Random_Array = CreateHeaderRandomArray(132, 0, Header_Random_Id_Array); public static readonly byte[] Header_Random_Array = CreateHeaderRandomArray(132, 0, Header_Random_Id_Array);
@ -120,11 +106,7 @@ namespace SixLabors.ImageSharp.Tests
); );
public static readonly IccProfile Profile_Random_Val = new IccProfile(CreateHeaderRandomValue(168, public static readonly IccProfile Profile_Random_Val = new IccProfile(CreateHeaderRandomValue(168,
#if !NETSTANDARD1_1
Profile_Random_Id_Value, Profile_Random_Id_Value,
#else
IccProfileId.Zero,
#endif
"acsp"), "acsp"),
new IccTagDataEntry[] new IccTagDataEntry[]
{ {
@ -239,4 +221,4 @@ namespace SixLabors.ImageSharp.Tests
new object[] { Header_Random_Array, true }, new object[] { Header_Random_Array, true },
}; };
} }
} }
Loading…
Cancel
Save