1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:18:47 +00:00

Compare commits

..

5 Commits

42 changed files with 11 additions and 420 deletions

View File

@ -23,7 +23,6 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x
6.0.x 6.0.x
7.0.x 7.0.x
@ -36,9 +35,6 @@ jobs:
- name: Build - name: Build
run: dotnet build --no-restore --configuration Release run: dotnet build --no-restore --configuration Release
- name: Test .NET Core 3.1
run: dotnet test --no-build --verbosity normal --configuration Release --framework netcoreapp3.1
- name: Test .NET 6 - name: Test .NET 6
run: dotnet test --no-build --verbosity normal --configuration Release --framework net6.0 run: dotnet test --no-build --verbosity normal --configuration Release --framework net6.0

View File

@ -46,6 +46,8 @@ TypeInitializationException.
- X10D: Removed `IEnumerable<T>.ConcatOne` - this functionality already exists with `Append`. - X10D: Removed `IEnumerable<T>.ConcatOne` - this functionality already exists with `Append`.
- X10D: Removed `Endianness` enum. - X10D: Removed `Endianness` enum.
- X10D: Removed .NET Standard 2.1 target.
- X10D.Hosting: Removed .NET Standard 2.1 target.
- X10D.DSharpPlus: Complete sunset of library. This library will not be updated to support DSharpPlus v5.0.0 (#83). - X10D.DSharpPlus: Complete sunset of library. This library will not be updated to support DSharpPlus v5.0.0 (#83).
- X10D.Unity: Complete sunset of library. This library will not be updated effective immediately (#86). - X10D.Unity: Complete sunset of library. This library will not be updated effective immediately (#86).

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject> <IsTestProject>true</IsTestProject>
<CoverletOutputFormat>json,cobertura</CoverletOutputFormat> <CoverletOutputFormat>json,cobertura</CoverletOutputFormat>

View File

@ -47,7 +47,6 @@ internal class ByteTests
}); });
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void UnpackInternal_Fallback_ShouldUnpackToSpanCorrectly() public void UnpackInternal_Fallback_ShouldUnpackToSpanCorrectly()
{ {
@ -92,7 +91,6 @@ internal class ByteTests
Assert.That(bits[7], Is.True); Assert.That(bits[7], Is.True);
}); });
} }
#endif
[Test] [Test]
public void Unpack_ShouldRepackEqually() public void Unpack_ShouldRepackEqually()

View File

@ -1,6 +1,4 @@
#if NET5_0_OR_GREATER
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif
using NUnit.Framework; using NUnit.Framework;
using X10D.Collections; using X10D.Collections;
@ -84,7 +82,6 @@ internal class Int16Tests
}); });
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void UnpackInternal_Ssse3_ShouldUnpackToSpanCorrectly() public void UnpackInternal_Ssse3_ShouldUnpackToSpanCorrectly()
{ {
@ -115,7 +112,6 @@ internal class Int16Tests
} }
}); });
} }
#endif
[Test] [Test]
public void Unpack_ShouldRepackEqually() public void Unpack_ShouldRepackEqually()

View File

@ -1,6 +1,4 @@
#if NET5_0_OR_GREATER
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif
using NUnit.Framework; using NUnit.Framework;
using X10D.Collections; using X10D.Collections;
@ -85,7 +83,6 @@ internal class Int32Tests
}); });
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void UnpackInternal_Ssse3_ShouldUnpackToSpanCorrectly() public void UnpackInternal_Ssse3_ShouldUnpackToSpanCorrectly()
{ {
@ -145,7 +142,6 @@ internal class Int32Tests
} }
}); });
} }
#endif
[Test] [Test]
public void Unpack_ShouldRepackEqually() public void Unpack_ShouldRepackEqually()

View File

@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using System.Runtime.Intrinsics; using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
using NUnit.Framework; using NUnit.Framework;
@ -223,4 +222,3 @@ internal class IntrinsicTests
Assert.That(result, Is.EqualTo(expectedResult)); Assert.That(result, Is.EqualTo(expectedResult));
} }
} }
#endif

View File

@ -1,7 +1,5 @@
#if NET5_0_OR_GREATER
using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif
using NUnit.Framework; using NUnit.Framework;
using X10D.Core; using X10D.Core;
@ -209,7 +207,6 @@ internal class SpanTest
Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.EqualTo(expected));
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void PackByteInternal_Sse2_ShouldReturnCorrectByte_GivenReadOnlySpan_Using() public void PackByteInternal_Sse2_ShouldReturnCorrectByte_GivenReadOnlySpan_Using()
{ {
@ -241,7 +238,6 @@ internal class SpanTest
Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.EqualTo(expected));
} }
#endif
[Test] [Test]
public void PackInt16_ShouldReturnSameAsPackByte_WhenSpanHasLength8() public void PackInt16_ShouldReturnSameAsPackByte_WhenSpanHasLength8()
@ -268,7 +264,6 @@ internal class SpanTest
Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.EqualTo(expected));
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void PackInt16Internal_Sse2_ShouldReturnCorrectInt16_GivenReadOnlySpan_Using() public void PackInt16Internal_Sse2_ShouldReturnCorrectInt16_GivenReadOnlySpan_Using()
{ {
@ -287,7 +282,6 @@ internal class SpanTest
Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.EqualTo(expected));
} }
#endif
[Test] [Test]
public void PackInt32Internal_Fallback_ShouldReturnCorrectInt32_GivenReadOnlySpan() public void PackInt32Internal_Fallback_ShouldReturnCorrectInt32_GivenReadOnlySpan()
@ -304,7 +298,6 @@ internal class SpanTest
Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.EqualTo(expected));
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void PackInt32Internal_Sse2_ShouldReturnCorrectInt32_GivenReadOnlySpan() public void PackInt32Internal_Sse2_ShouldReturnCorrectInt32_GivenReadOnlySpan()
{ {
@ -364,7 +357,6 @@ internal class SpanTest
Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.EqualTo(expected));
} }
#endif
[Test] [Test]
public void PackInt32_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingReadOnlySpan() public void PackInt32_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingReadOnlySpan()

View File

@ -207,9 +207,7 @@ internal class ColorTests
Assert.That(Color.Plum.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray)); Assert.That(Color.Plum.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray));
Assert.That(Color.PowderBlue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray)); Assert.That(Color.PowderBlue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray));
Assert.That(Color.Purple.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkMagenta)); Assert.That(Color.Purple.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkMagenta));
#if NET6_0_OR_GREATER
Assert.That(Color.RebeccaPurple.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkMagenta)); Assert.That(Color.RebeccaPurple.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkMagenta));
#endif
Assert.That(Color.Red.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red)); Assert.That(Color.Red.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red));
Assert.That(Color.RosyBrown.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray)); Assert.That(Color.RosyBrown.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray));
Assert.That(Color.RoyalBlue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkCyan)); Assert.That(Color.RoyalBlue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkCyan));

View File

@ -6,7 +6,6 @@ namespace X10D.Tests.Text;
[TestFixture] [TestFixture]
internal class CoreTests internal class CoreTests
{ {
#if NET5_0_OR_GREATER
[Test] [Test]
public void ToJsonShouldNotBeEmpty() public void ToJsonShouldNotBeEmpty()
{ {
@ -24,5 +23,4 @@ internal class CoreTests
CollectionAssert.AreEqual(source, target); CollectionAssert.AreEqual(source, target);
CollectionAssert.AreEquivalent(source, target); CollectionAssert.AreEquivalent(source, target);
} }
#endif
} }

View File

@ -1,4 +1,3 @@
#if NET5_0_OR_GREATER
using System.Text; using System.Text;
using NUnit.Framework; using NUnit.Framework;
using X10D.Text; using X10D.Text;
@ -90,4 +89,3 @@ internal class RuneTests
Assert.That(repeated, Is.EqualTo("𐀀𐀀𐀀𐀀𐀀𐀀")); Assert.That(repeated, Is.EqualTo("𐀀𐀀𐀀𐀀𐀀𐀀"));
} }
} }
#endif

View File

@ -1,7 +1,5 @@
using System.Text; using System.Text;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
#endif
using NUnit.Framework; using NUnit.Framework;
using X10D.Text; using X10D.Text;
@ -418,7 +416,6 @@ internal class StringTests
Assert.Throws<ArgumentException>(() => _ = " ".EnumParse<DayOfWeek>()); Assert.Throws<ArgumentException>(() => _ = " ".EnumParse<DayOfWeek>());
} }
#if NET5_0_OR_GREATER
[Test] [Test]
public void FromJson_ShouldDeserializeCorrectly_GivenJsonString() public void FromJson_ShouldDeserializeCorrectly_GivenJsonString()
{ {
@ -434,7 +431,6 @@ internal class StringTests
Assert.That(target.Values[2], Is.EqualTo(3)); Assert.That(target.Values[2], Is.EqualTo(3));
}); });
} }
#endif
[Test] [Test]
public void GetBytes_ShouldReturnUtf8Bytes_GivenHelloWorld() public void GetBytes_ShouldReturnUtf8Bytes_GivenHelloWorld()
@ -1006,11 +1002,9 @@ internal class StringTests
}); });
} }
#if NET5_0_OR_GREATER
private struct SampleStructure private struct SampleStructure
{ {
[JsonPropertyName("values")] [JsonPropertyName("values")]
public int[] Values { get; set; } public int[] Values { get; set; }
} }
#endif
} }

View File

@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using NUnit.Framework; using NUnit.Framework;
using X10D.Time; using X10D.Time;
@ -230,4 +229,3 @@ internal class DateOnlyTests
Assert.That(date.ToUnixTimeSeconds(time), Is.EqualTo(946684800)); Assert.That(date.ToUnixTimeSeconds(time), Is.EqualTo(946684800));
} }
} }
#endif

View File

@ -1,4 +1,3 @@
#if NET5_0_OR_GREATER
using NUnit.Framework; using NUnit.Framework;
using X10D.Time; using X10D.Time;
@ -52,4 +51,3 @@ internal class DoubleTests
Assert.That((_negativeOne).Weeks() < TimeSpan.Zero); Assert.That((_negativeOne).Weeks() < TimeSpan.Zero);
} }
} }
#endif

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,12 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using X10D.CompilerServices;
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Intrinsics; using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif using X10D.CompilerServices;
namespace X10D.Collections; namespace X10D.Collections;
@ -46,13 +43,11 @@ public static class ByteExtensions
throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination)); throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination));
} }
#if NETCOREAPP3_0_OR_GREATER
if (Sse3.IsSupported) if (Sse3.IsSupported)
{ {
UnpackInternal_Ssse3(value, destination); UnpackInternal_Ssse3(value, destination);
return; return;
} }
#endif
UnpackInternal_Fallback(value, destination); UnpackInternal_Fallback(value, destination);
} }
@ -66,7 +61,6 @@ public static class ByteExtensions
} }
} }
#if NETCOREAPP3_0_OR_GREATER
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal unsafe static void UnpackInternal_Ssse3(this byte value, Span<bool> destination) internal unsafe static void UnpackInternal_Ssse3(this byte value, Span<bool> destination)
{ {
@ -87,5 +81,4 @@ public static class ByteExtensions
Sse2.StoreScalar((long*)pDestination, correctness.AsInt64()); Sse2.StoreScalar((long*)pDestination, correctness.AsInt64());
} }
} }
#endif
} }

View File

@ -1,7 +1,5 @@
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
#if NET6_0_OR_GREATER
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#endif
using System.Web; using System.Web;
namespace X10D.Collections; namespace X10D.Collections;
@ -47,23 +45,10 @@ public static class DictionaryExtensions
throw new ArgumentNullException(nameof(updateValueFactory)); throw new ArgumentNullException(nameof(updateValueFactory));
} }
#if NET6_0_OR_GREATER
ref var value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists); ref var value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists);
// DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above. // DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above.
// mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake. // mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake.
return value = exists ? updateValueFactory(key, value!) : addValue; return value = exists ? updateValueFactory(key, value!) : addValue;
#else
if (dictionary.TryGetValue(key, out TValue? old))
{
TValue updated = updateValueFactory(key, old);
dictionary[key] = updated;
return updated;
}
dictionary.Add(key, addValue);
return addValue;
#endif
} }
/// <summary> /// <summary>
@ -157,25 +142,10 @@ public static class DictionaryExtensions
throw new ArgumentNullException(nameof(updateValueFactory)); throw new ArgumentNullException(nameof(updateValueFactory));
} }
#if NET6_0_OR_GREATER
ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists); ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists);
// DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above. // DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above.
// mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake. // mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake.
return value = exists ? updateValueFactory(key, value!) : addValueFactory(key); return value = exists ? updateValueFactory(key, value!) : addValueFactory(key);
#else
if (dictionary.TryGetValue(key, out TValue? old))
{
TValue updated = updateValueFactory(key, old);
dictionary[key] = updated;
return updated;
}
TValue add = addValueFactory(key);
dictionary.Add(key, add);
return add;
#endif
} }
/// <summary> /// <summary>
@ -284,25 +254,10 @@ public static class DictionaryExtensions
throw new ArgumentNullException(nameof(updateValueFactory)); throw new ArgumentNullException(nameof(updateValueFactory));
} }
#if NET6_0_OR_GREATER
ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists); ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists);
// DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above. // DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above.
// mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake. // mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake.
return value = exists ? updateValueFactory(key, value!, factoryArgument) : addValueFactory(key, factoryArgument); return value = exists ? updateValueFactory(key, value!, factoryArgument) : addValueFactory(key, factoryArgument);
#else
if (dictionary.TryGetValue(key, out TValue? old))
{
TValue updated = updateValueFactory(key, old, factoryArgument);
dictionary[key] = updated;
return updated;
}
TValue add = addValueFactory(key, factoryArgument);
dictionary.Add(key, add);
return add;
#endif
} }
/// <summary> /// <summary>

View File

@ -1,12 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using X10D.CompilerServices;
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Intrinsics; using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif using X10D.CompilerServices;
namespace X10D.Collections; namespace X10D.Collections;
@ -46,13 +43,11 @@ public static class Int16Extensions
throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination)); throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination));
} }
#if NETCOREAPP3_0_OR_GREATER
if (Sse3.IsSupported) if (Sse3.IsSupported)
{ {
UnpackInternal_Ssse3(value, destination); UnpackInternal_Ssse3(value, destination);
return; return;
} }
#endif
UnpackInternal_Fallback(value, destination); UnpackInternal_Fallback(value, destination);
} }
@ -66,7 +61,6 @@ public static class Int16Extensions
} }
} }
#if NETCOREAPP3_0_OR_GREATER
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal unsafe static void UnpackInternal_Ssse3(this short value, Span<bool> destination) internal unsafe static void UnpackInternal_Ssse3(this short value, Span<bool> destination)
{ {
@ -89,5 +83,4 @@ public static class Int16Extensions
Sse2.Store((byte*)pDestination, correctness); Sse2.Store((byte*)pDestination, correctness);
} }
} }
#endif
} }

View File

@ -1,12 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using X10D.CompilerServices;
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Intrinsics; using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif using X10D.CompilerServices;
namespace X10D.Collections; namespace X10D.Collections;
@ -46,7 +43,6 @@ public static class Int32Extensions
throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination)); throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination));
} }
#if NETCOREAPP3_0_OR_GREATER
if (Avx2.IsSupported) if (Avx2.IsSupported)
{ {
UnpackInternal_Avx2(value, destination); UnpackInternal_Avx2(value, destination);
@ -58,7 +54,6 @@ public static class Int32Extensions
UnpackInternal_Ssse3(value, destination); UnpackInternal_Ssse3(value, destination);
return; return;
} }
#endif
UnpackInternal_Fallback(value, destination); UnpackInternal_Fallback(value, destination);
} }
@ -72,7 +67,6 @@ public static class Int32Extensions
} }
} }
#if NETCOREAPP3_0_OR_GREATER
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal static unsafe void UnpackInternal_Ssse3(this int value, Span<bool> destination) internal static unsafe void UnpackInternal_Ssse3(this int value, Span<bool> destination)
{ {
@ -130,5 +124,4 @@ public static class Int32Extensions
Avx.Store((byte*)pDestination, correctness); Avx.Store((byte*)pDestination, correctness);
} }
} }
#endif
} }

View File

@ -4,10 +4,6 @@ namespace X10D.CompilerServices;
internal static class CompilerResources internal static class CompilerResources
{ {
#if NETCOREAPP3_0_OR_GREATER
public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining | public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining |
System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization; System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization;
#else
public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining;
#endif
} }

View File

@ -20,11 +20,7 @@ public static class EnumExtensions
public static T Next<T>(this T value) public static T Next<T>(this T value)
where T : struct, Enum where T : struct, Enum
{ {
#if NET5_0_OR_GREATER
T[] values = Enum.GetValues<T>(); T[] values = Enum.GetValues<T>();
#else
T[] values = Enum.GetValues(typeof(T)).Cast<T>().ToArray();
#endif
int index = Array.IndexOf(values, value) + 1; int index = Array.IndexOf(values, value) + 1;
index %= values.Length; index %= values.Length;
return values[index]; return values[index];
@ -44,11 +40,7 @@ public static class EnumExtensions
public static T NextUnchecked<T>(this T value) public static T NextUnchecked<T>(this T value)
where T : struct, Enum where T : struct, Enum
{ {
#if NET5_0_OR_GREATER
T[] values = Enum.GetValues<T>(); T[] values = Enum.GetValues<T>();
#else
T[] values = Enum.GetValues(typeof(T)).Cast<T>().ToArray();
#endif
int index = Array.IndexOf(values, value) + 1; int index = Array.IndexOf(values, value) + 1;
return values[index]; return values[index];
} }
@ -66,11 +58,7 @@ public static class EnumExtensions
public static T Previous<T>(this T value) public static T Previous<T>(this T value)
where T : struct, Enum where T : struct, Enum
{ {
#if NET5_0_OR_GREATER
T[] values = Enum.GetValues<T>(); T[] values = Enum.GetValues<T>();
#else
T[] values = Enum.GetValues(typeof(T)).Cast<T>().ToArray();
#endif
int index = Array.IndexOf(values, value) - 1; int index = Array.IndexOf(values, value) - 1;
int length = values.Length; int length = values.Length;
@ -94,11 +82,7 @@ public static class EnumExtensions
public static T PreviousUnchecked<T>(this T value) public static T PreviousUnchecked<T>(this T value)
where T : struct, Enum where T : struct, Enum
{ {
#if NET5_0_OR_GREATER
T[] values = Enum.GetValues<T>(); T[] values = Enum.GetValues<T>();
#else
T[] values = Enum.GetValues(typeof(T)).Cast<T>().ToArray();
#endif
int index = Array.IndexOf(values, value) - 1; int index = Array.IndexOf(values, value) - 1;
return values[index]; return values[index];
} }

View File

@ -1,4 +1,3 @@
#if NETCOREAPP3_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -188,4 +187,3 @@ public static class IntrinsicExtensions
return Sse2.Shuffle(vector.AsDouble(), vector.AsDouble(), 0b01).AsUInt64(); return Sse2.Shuffle(vector.AsDouble(), vector.AsDouble(), 0b01).AsUInt64();
} }
} }
#endif

View File

@ -1,5 +1,3 @@
#if NETCOREAPP3_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -184,34 +182,22 @@ public static class IntrinsicUtility
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal static Vector64<T> GetUninitializedVector64<T>() where T : struct internal static Vector64<T> GetUninitializedVector64<T>() where T : struct
{ {
#if NET6_0_OR_GREATER
Unsafe.SkipInit(out Vector64<T> output); Unsafe.SkipInit(out Vector64<T> output);
return output; return output;
#else
return default;
#endif
} }
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal static Vector128<T> GetUninitializedVector128<T>() where T : struct internal static Vector128<T> GetUninitializedVector128<T>() where T : struct
{ {
#if NET6_0_OR_GREATER
Unsafe.SkipInit(out Vector128<T> output); Unsafe.SkipInit(out Vector128<T> output);
return output; return output;
#else
return default;
#endif
} }
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal static Vector256<T> GetUninitializedVector256<T>() where T : struct internal static Vector256<T> GetUninitializedVector256<T>() where T : struct
{ {
#if NET6_0_OR_GREATER
Unsafe.SkipInit(out Vector256<T> output); Unsafe.SkipInit(out Vector256<T> output);
return output; return output;
#else
return default;
#endif
} }
[Pure] [Pure]
@ -315,5 +301,3 @@ public static class IntrinsicUtility
return Avx2.Add(high, ac); return Avx2.Add(high, ac);
} }
} }
#endif

View File

@ -11,10 +11,6 @@ namespace X10D.Core;
/// </summary> /// </summary>
public static class RandomExtensions public static class RandomExtensions
{ {
#if !NET6_0_OR_GREATER
private static readonly Random Shared = new();
#endif
/// <summary> /// <summary>
/// Returns a random value that defined in a specified enum. /// Returns a random value that defined in a specified enum.
/// </summary> /// </summary>
@ -505,10 +501,6 @@ public static class RandomExtensions
internal static Random GetShared() internal static Random GetShared()
{ {
#if NET6_0_OR_GREATER
return Random.Shared; return Random.Shared;
#else
return Shared;
#endif
} }
} }

View File

@ -2,13 +2,10 @@ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using X10D.CompilerServices;
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Intrinsics; using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Arm;
#endif using X10D.CompilerServices;
#if NET7_0_OR_GREATER #if NET7_0_OR_GREATER
using System.Diagnostics; using System.Diagnostics;
@ -21,7 +18,6 @@ namespace X10D.Core;
/// </summary> /// </summary>
public static class SpanExtensions public static class SpanExtensions
{ {
#if NETCOREAPP3_0_OR_GREATER
private const ulong IntegerPackingMagic = 0x0102040810204080; private const ulong IntegerPackingMagic = 0x0102040810204080;
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
@ -35,7 +31,6 @@ public static class SpanExtensions
{ {
get => Vector256.Create(IntegerPackingMagic); get => Vector256.Create(IntegerPackingMagic);
} }
#endif
/// <summary> /// <summary>
/// Returns a value indicating whether a specific enumeration value is contained with the current span of elements. /// Returns a value indicating whether a specific enumeration value is contained with the current span of elements.
@ -71,7 +66,6 @@ public static class SpanExtensions
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : struct, Enum public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : struct, Enum
{ {
#if NET6_0_OR_GREATER
unsafe unsafe
{ {
#pragma warning disable CS8500 #pragma warning disable CS8500
@ -114,17 +108,6 @@ public static class SpanExtensions
// dotcover enable // dotcover enable
} }
} }
#else
foreach (var it in span)
{
if (EqualityComparer<T>.Default.Equals(it, value))
{
return true;
}
}
return false;
#endif
} }
/// <summary> /// <summary>
@ -161,7 +144,6 @@ public static class SpanExtensions
return PackByteInternal_Fallback(source); return PackByteInternal_Fallback(source);
} }
#if NETCOREAPP3_0_OR_GREATER
if (!BitConverter.IsLittleEndian) if (!BitConverter.IsLittleEndian)
{ {
return PackByteInternal_Fallback(source); return PackByteInternal_Fallback(source);
@ -176,7 +158,6 @@ public static class SpanExtensions
{ {
return PackByteInternal_AdvSimd(source); return PackByteInternal_AdvSimd(source);
} }
#endif
return PackByteInternal_Fallback(source); return PackByteInternal_Fallback(source);
} }
@ -217,12 +198,10 @@ public static class SpanExtensions
goto default; goto default;
} }
#if NETCOREAPP3_0_OR_GREATER
if (Sse2.IsSupported) if (Sse2.IsSupported)
{ {
return PackInt16Internal_Sse2(source); return PackInt16Internal_Sse2(source);
} }
#endif
goto default; goto default;
case < 16: case < 16:
@ -269,7 +248,6 @@ public static class SpanExtensions
return PackInt16(source); return PackInt16(source);
case 32: case 32:
#if NETCOREAPP3_0_OR_GREATER
if (!BitConverter.IsLittleEndian) if (!BitConverter.IsLittleEndian)
{ {
goto default; goto default;
@ -289,7 +267,6 @@ public static class SpanExtensions
{ {
return PackInt32Internal_AdvSimd(source); return PackInt32Internal_AdvSimd(source);
} }
#endif
goto default; goto default;
default: default:
@ -383,7 +360,6 @@ public static class SpanExtensions
return result; return result;
} }
#if NETCOREAPP3_0_OR_GREATER
[Pure] [Pure]
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source) internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source)
@ -499,7 +475,6 @@ public static class SpanExtensions
} }
} }
#if NET5_0_OR_GREATER
// dotcover disable // dotcover disable
//NOSONAR //NOSONAR
[Pure] [Pure]
@ -517,6 +492,4 @@ public static class SpanExtensions
} }
//NOSONAR //NOSONAR
// dotcover enable // dotcover enable
#endif
#endif
} }

View File

@ -72,17 +72,9 @@ public static class ColorExtensions
double blue = color.B; double blue = color.B;
var delta = double.MaxValue; var delta = double.MaxValue;
#if NET5_0_OR_GREATER
foreach (ConsoleColor consoleColor in Enum.GetValues<ConsoleColor>()) foreach (ConsoleColor consoleColor in Enum.GetValues<ConsoleColor>())
#else
foreach (ConsoleColor consoleColor in Enum.GetValues(typeof(ConsoleColor)))
#endif
{ {
#if NET5_0_OR_GREATER
string name = Enum.GetName(consoleColor)!; string name = Enum.GetName(consoleColor)!;
#else
string name = Enum.GetName(typeof(ConsoleColor), consoleColor)!;
#endif
Color currentColor = Color.FromName(name == "DarkYellow" ? "Orange" : name); // bug fix Color currentColor = Color.FromName(name == "DarkYellow" ? "Orange" : name); // bug fix
double r = currentColor.R - red; double r = currentColor.R - red;
double g = currentColor.G - green; double g = currentColor.G - green;

View File

@ -93,13 +93,7 @@ public static class DecimalExtensions
private static void GetBits(decimal value, Span<int> destination) private static void GetBits(decimal value, Span<int> destination)
{ {
#if NET5_0_OR_GREATER
_ = decimal.GetBits(value, destination); _ = decimal.GetBits(value, destination);
#else
Span<byte> buffer = stackalloc byte[16];
MemoryMarshal.Write(buffer, ref value);
WriteBits(destination, buffer);
#endif
} }
#if !NET5_0_OR_GREATER #if !NET5_0_OR_GREATER

View File

@ -43,17 +43,7 @@ public static class DoubleExtensions
/// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns> /// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns>
public static bool TryWriteBigEndianBytes(this double value, Span<byte> destination) public static bool TryWriteBigEndianBytes(this double value, Span<byte> destination)
{ {
#if NET5_0_OR_GREATER
return BinaryPrimitives.TryWriteDoubleBigEndian(destination, value); return BinaryPrimitives.TryWriteDoubleBigEndian(destination, value);
#else
if (BitConverter.IsLittleEndian)
{
long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
}
return MemoryMarshal.TryWrite(destination, ref value);
#endif
} }
/// <summary> /// <summary>
@ -64,16 +54,6 @@ public static class DoubleExtensions
/// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns> /// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns>
public static bool TryWriteLittleEndianBytes(this double value, Span<byte> destination) public static bool TryWriteLittleEndianBytes(this double value, Span<byte> destination)
{ {
#if NET5_0_OR_GREATER
return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value); return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value);
#else
if (BitConverter.IsLittleEndian)
{
return MemoryMarshal.TryWrite(destination, ref value);
}
long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
#endif
} }
} }

View File

@ -45,17 +45,7 @@ public static class SingleExtensions
/// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns> /// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns>
public static bool TryWriteBigEndianBytes(this float value, Span<byte> destination) public static bool TryWriteBigEndianBytes(this float value, Span<byte> destination)
{ {
#if NET5_0_OR_GREATER
return BinaryPrimitives.TryWriteSingleBigEndian(destination, value); return BinaryPrimitives.TryWriteSingleBigEndian(destination, value);
#else
if (BitConverter.IsLittleEndian)
{
int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
}
return MemoryMarshal.TryWrite(destination, ref value);
#endif
} }
/// <summary> /// <summary>
@ -66,16 +56,6 @@ public static class SingleExtensions
/// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns> /// <returns><see langword="true" /> if the conversion was successful; otherwise, <see langword="false" />.</returns>
public static bool TryWriteLittleEndianBytes(this float value, Span<byte> destination) public static bool TryWriteLittleEndianBytes(this float value, Span<byte> destination)
{ {
#if NET5_0_OR_GREATER
return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value); return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value);
#else
if (BitConverter.IsLittleEndian)
{
return MemoryMarshal.TryWrite(destination, ref value);
}
int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
#endif
} }
} }

View File

@ -1,5 +1,4 @@
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Runtime.InteropServices;
namespace X10D.IO; namespace X10D.IO;
@ -40,11 +39,7 @@ public static partial class StreamExtensions
buffer.Reverse(); buffer.Reverse();
} }
#if NET5_0_OR_GREATER
return new decimal(buffer); return new decimal(buffer);
#else
return new decimal(buffer.ToArray());
#endif
} }
/// <summary> /// <summary>
@ -82,11 +77,7 @@ public static partial class StreamExtensions
buffer.Reverse(); buffer.Reverse();
} }
#if NET5_0_OR_GREATER
return new decimal(buffer); return new decimal(buffer);
#else
return new decimal(buffer.ToArray());
#endif
} }
/// <summary> /// <summary>
@ -110,16 +101,7 @@ public static partial class StreamExtensions
Span<byte> buffer = stackalloc byte[8]; Span<byte> buffer = stackalloc byte[8];
_ = stream.Read(buffer); _ = stream.Read(buffer);
#if NET5_0_OR_GREATER
return BinaryPrimitives.ReadDoubleBigEndian(buffer); return BinaryPrimitives.ReadDoubleBigEndian(buffer);
#else
if (BitConverter.IsLittleEndian)
{
buffer.Reverse();
}
return MemoryMarshal.Read<double>(buffer);
#endif
} }
/// <summary> /// <summary>
@ -144,16 +126,7 @@ public static partial class StreamExtensions
Span<byte> buffer = stackalloc byte[8]; Span<byte> buffer = stackalloc byte[8];
_ = stream.Read(buffer); _ = stream.Read(buffer);
#if NET5_0_OR_GREATER
return BinaryPrimitives.ReadDoubleLittleEndian(buffer); return BinaryPrimitives.ReadDoubleLittleEndian(buffer);
#else
if (!BitConverter.IsLittleEndian)
{
buffer.Reverse();
}
return MemoryMarshal.Read<double>(buffer);
#endif
} }
/// <summary> /// <summary>
@ -323,16 +296,7 @@ public static partial class StreamExtensions
Span<byte> buffer = stackalloc byte[4]; Span<byte> buffer = stackalloc byte[4];
_ = stream.Read(buffer); _ = stream.Read(buffer);
#if NET5_0_OR_GREATER
return BinaryPrimitives.ReadSingleBigEndian(buffer); return BinaryPrimitives.ReadSingleBigEndian(buffer);
#else
if (BitConverter.IsLittleEndian)
{
buffer.Reverse();
}
return MemoryMarshal.Read<float>(buffer);
#endif
} }
/// <summary> /// <summary>
@ -358,16 +322,7 @@ public static partial class StreamExtensions
Span<byte> buffer = stackalloc byte[4]; Span<byte> buffer = stackalloc byte[4];
_ = stream.Read(buffer); _ = stream.Read(buffer);
#if NET5_0_OR_GREATER
return BinaryPrimitives.ReadSingleLittleEndian(buffer); return BinaryPrimitives.ReadSingleLittleEndian(buffer);
#else
if (!BitConverter.IsLittleEndian)
{
buffer.Reverse();
}
return MemoryMarshal.Read<float>(buffer);
#endif
} }
/// <summary> /// <summary>

View File

@ -1,6 +1,4 @@
#if NET5_0_OR_GREATER
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#endif
namespace X10D.Linq; namespace X10D.Linq;
@ -389,11 +387,9 @@ public static class EnumerableExtensions
span = array; span = array;
break; break;
#if NET5_0_OR_GREATER
case List<TSource> list: case List<TSource> list:
span = CollectionsMarshal.AsSpan(list); span = CollectionsMarshal.AsSpan(list);
break; break;
#endif
default: default:
span = default; span = default;

View File

@ -253,15 +253,7 @@ public static class MathUtility
public static float Pulse(float value, float lowerBound, float upperBound) public static float Pulse(float value, float lowerBound, float upperBound)
{ {
bool result = lowerBound <= value && value <= upperBound; bool result = lowerBound <= value && value <= upperBound;
#if NET6_0_OR_GREATER
return Unsafe.As<bool, int>(ref result); return Unsafe.As<bool, int>(ref result);
#else
unsafe
{
var pResult = (int*)&result;
return *pResult;
}
#endif
} }
/// <summary> /// <summary>
@ -277,15 +269,7 @@ public static class MathUtility
public static double Pulse(double value, double lowerBound, double upperBound) public static double Pulse(double value, double lowerBound, double upperBound)
{ {
bool result = lowerBound <= value && value <= upperBound; bool result = lowerBound <= value && value <= upperBound;
#if NET6_0_OR_GREATER
return Unsafe.As<bool, int>(ref result); return Unsafe.As<bool, int>(ref result);
#else
unsafe
{
var pResult = (int*)&result;
return *pResult;
}
#endif
} }
/// <summary> /// <summary>

View File

@ -24,20 +24,7 @@ public static class UInt32Extensions
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
public static int PopCount(this uint value) public static int PopCount(this uint value)
{ {
#if NETCOREAPP3_1_OR_GREATER
return BitOperations.PopCount(value); return BitOperations.PopCount(value);
#else
const uint c1 = 0x_55555555u;
const uint c2 = 0x_33333333u;
const uint c3 = 0x_0F0F0F0Fu;
const uint c4 = 0x_01010101u;
value -= (value >> 1) & c1;
value = (value & c2) + ((value >> 2) & c2);
value = (((value + (value >> 4)) & c3) * c4) >> 24;
return (int)value;
#endif
} }
/// <summary> /// <summary>
@ -82,17 +69,6 @@ public static class UInt32Extensions
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
public static uint RoundUpToPowerOf2(this uint value) public static uint RoundUpToPowerOf2(this uint value)
{ {
#if NET6_0_OR_GREATER
return BitOperations.RoundUpToPowerOf2(value); return BitOperations.RoundUpToPowerOf2(value);
#else
// Based on https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
--value;
value |= value >> 1;
value |= value >> 2;
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
return value + 1;
#endif
} }
} }

View File

@ -24,20 +24,7 @@ public static class UInt64Extensions
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
public static int PopCount(this ulong value) public static int PopCount(this ulong value)
{ {
#if NETCOREAPP3_1_OR_GREATER
return BitOperations.PopCount(value); return BitOperations.PopCount(value);
#else
const ulong c1 = 0x_55555555_55555555ul;
const ulong c2 = 0x_33333333_33333333ul;
const ulong c3 = 0x_0F0F0F0F_0F0F0F0Ful;
const ulong c4 = 0x_01010101_01010101ul;
value -= (value >> 1) & c1;
value = (value & c2) + ((value >> 2) & c2);
value = (((value + (value >> 4)) & c3) * c4) >> 56;
return (int)value;
#endif
} }
/// <summary> /// <summary>
@ -82,18 +69,6 @@ public static class UInt64Extensions
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]
public static ulong RoundUpToPowerOf2(this ulong value) public static ulong RoundUpToPowerOf2(this ulong value)
{ {
#if NET6_0_OR_GREATER
return BitOperations.RoundUpToPowerOf2(value); return BitOperations.RoundUpToPowerOf2(value);
#else
// Based on https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
--value;
value |= value >> 1;
value |= value >> 2;
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
value |= value >> 32;
return value + 1;
#endif
} }
} }

View File

@ -55,12 +55,10 @@ public static class EnumerableExtensions
throw new ArgumentNullException(nameof(pattern)); throw new ArgumentNullException(nameof(pattern));
} }
#if NET6_0_OR_GREATER
if (source.TryGetNonEnumeratedCount(out int count) && count == 0) if (source.TryGetNonEnumeratedCount(out int count) && count == 0)
{ {
yield break; yield break;
} }
#endif
var options = RegexOptions.Compiled | (ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None); var options = RegexOptions.Compiled | (ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None);
var regex = new Regex(pattern, options, Regex.InfiniteMatchTimeout); var regex = new Regex(pattern, options, Regex.InfiniteMatchTimeout);

View File

@ -1,4 +1,3 @@
#if NET5_0_OR_GREATER
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json; using System.Text.Json;
@ -25,4 +24,3 @@ public static class Extensions
return JsonSerializer.Serialize(value, options); return JsonSerializer.Serialize(value, options);
} }
} }
#endif

View File

@ -1,4 +1,3 @@
#if NETCOREAPP3_0_OR_GREATER
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Globalization; using System.Globalization;
@ -113,4 +112,3 @@ public static class RuneExtensions
} }
} }
} }
#endif

View File

@ -2,9 +2,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
#if NET5_0_OR_GREATER
using System.Text.Json; using System.Text.Json;
#endif
using X10D.Collections; using X10D.Collections;
using X10D.CompilerServices; using X10D.CompilerServices;
using X10D.Core; using X10D.Core;
@ -575,7 +573,6 @@ public static class StringExtensions
return Enum.Parse<T>(value, ignoreCase); return Enum.Parse<T>(value, ignoreCase);
} }
#if NET5_0_OR_GREATER
/// <summary> /// <summary>
/// Returns an object from the specified JSON string. /// Returns an object from the specified JSON string.
/// </summary> /// </summary>
@ -590,7 +587,6 @@ public static class StringExtensions
{ {
return JsonSerializer.Deserialize<T>(value, options); return JsonSerializer.Deserialize<T>(value, options);
} }
#endif
/// <summary> /// <summary>
/// Gets a <see cref="byte" />[] representing the value the <see cref="string" /> with /// Gets a <see cref="byte" />[] representing the value the <see cref="string" /> with
@ -688,7 +684,6 @@ public static class StringExtensions
for (var index = 0; index < value.Length; index++) for (var index = 0; index < value.Length; index++)
{ {
#if NETCOREAPP3_0_OR_GREATER
var rune = new Rune(value[index]); var rune = new Rune(value[index]);
if (!Rune.IsLetter(rune)) if (!Rune.IsLetter(rune))
@ -700,19 +695,6 @@ public static class StringExtensions
{ {
return false; return false;
} }
#else
char current = value[index];
if (!char.IsLetter(current))
{
continue;
}
if (!char.IsLower(current))
{
return false;
}
#endif
} }
return true; return true;
@ -777,7 +759,6 @@ public static class StringExtensions
for (int index = 0, endIndex = value.Length - 1; index < value.Length; index++, endIndex--) for (int index = 0, endIndex = value.Length - 1; index < value.Length; index++, endIndex--)
{ {
#if NETCOREAPP3_0_OR_GREATER
Rune startRune = new Rune(value[index]); Rune startRune = new Rune(value[index]);
Rune endRune = new Rune(value[endIndex]); Rune endRune = new Rune(value[endIndex]);
@ -797,27 +778,6 @@ public static class StringExtensions
{ {
return false; return false;
} }
#else
char startChar = value[index];
char endChar = value[endIndex];
if (!char.IsLetter(startChar) && !char.IsNumber(startChar))
{
endIndex++;
continue;
}
if (!char.IsLetter(endChar) && !char.IsNumber(endChar))
{
index--;
continue;
}
if (char.ToUpperInvariant(startChar) != char.ToUpperInvariant(endChar))
{
return false;
}
#endif
} }
return true; return true;
@ -841,7 +801,6 @@ public static class StringExtensions
for (var index = 0; index < value.Length; index++) for (var index = 0; index < value.Length; index++)
{ {
#if NETCOREAPP3_0_OR_GREATER
var rune = new Rune(value[index]); var rune = new Rune(value[index]);
if (!Rune.IsLetter(rune)) if (!Rune.IsLetter(rune))
@ -853,19 +812,6 @@ public static class StringExtensions
{ {
return false; return false;
} }
#else
char current = value[index];
if (!char.IsLetter(current))
{
continue;
}
if (!char.IsUpper(current))
{
return false;
}
#endif
} }
return true; return true;

View File

@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -198,4 +197,3 @@ public static class DateOnlyExtensions
return value.ToDateTime(time).ToUnixTimeSeconds(); return value.ToDateTime(time).ToUnixTimeSeconds();
} }
} }
#endif

View File

@ -1,4 +1,3 @@
#if NET5_0_OR_GREATER
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using X10D.CompilerServices; using X10D.CompilerServices;
@ -92,4 +91,3 @@ public static class HalfExtensions
return TimeSpan.FromDays((float)value * 7); return TimeSpan.FromDays((float)value * 7);
} }
} }
#endif

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<Optimize>true</Optimize> <Optimize>true</Optimize>