From a0fde872ec7fc10625b207422828db2ae71de5b6 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:48:05 +0300 Subject: [PATCH] Replace polyfills with PolyShim --- CliFx.Analyzers/CliFx.Analyzers.csproj | 3 ++- CliFx/CliFx.csproj | 9 +++------ CliFx/Utils/Polyfills.Collections.cs | 26 -------------------------- CliFx/Utils/Polyfills.Regex.cs | 12 ------------ CliFx/Utils/Polyfills.Streams.cs | 11 ----------- CliFx/Utils/Polyfills.Strings.cs | 12 ------------ 6 files changed, 5 insertions(+), 68 deletions(-) delete mode 100644 CliFx/Utils/Polyfills.Collections.cs delete mode 100644 CliFx/Utils/Polyfills.Regex.cs delete mode 100644 CliFx/Utils/Polyfills.Streams.cs delete mode 100644 CliFx/Utils/Polyfills.Strings.cs diff --git a/CliFx.Analyzers/CliFx.Analyzers.csproj b/CliFx.Analyzers/CliFx.Analyzers.csproj index 41abe74..841f807 100644 --- a/CliFx.Analyzers/CliFx.Analyzers.csproj +++ b/CliFx.Analyzers/CliFx.Analyzers.csproj @@ -6,7 +6,7 @@ true $(NoWarn);RS1025;RS1026 - + diff --git a/CliFx/Utils/Polyfills.Collections.cs b/CliFx/Utils/Polyfills.Collections.cs deleted file mode 100644 index 7c3cbed..0000000 --- a/CliFx/Utils/Polyfills.Collections.cs +++ /dev/null @@ -1,26 +0,0 @@ -// ReSharper disable CheckNamespace - -#if NETSTANDARD2_0 -using System.Collections.Generic; - -internal static class CollectionPolyfills -{ - public static void Deconstruct(this KeyValuePair pair, out TKey key, out TValue value) - { - key = pair.Key; - value = pair.Value; - } - - public static TValue GetValueOrDefault(this IReadOnlyDictionary dic, TKey key) => - dic.TryGetValue(key!, out var result) ? result! : default!; -} - -namespace System.Linq -{ - internal static class LinqPolyfills - { - public static HashSet ToHashSet(this IEnumerable source, IEqualityComparer comparer) => - new(source, comparer); - } -} -#endif \ No newline at end of file diff --git a/CliFx/Utils/Polyfills.Regex.cs b/CliFx/Utils/Polyfills.Regex.cs deleted file mode 100644 index bd354eb..0000000 --- a/CliFx/Utils/Polyfills.Regex.cs +++ /dev/null @@ -1,12 +0,0 @@ -// ReSharper disable CheckNamespace - -#if NETSTANDARD2_0 -using System.Linq; -using System.Text.RegularExpressions; - -internal static class RegexPolyfills -{ - public static Match[] ToArray(this MatchCollection matches) => - matches.Cast().ToArray(); -} -#endif \ No newline at end of file diff --git a/CliFx/Utils/Polyfills.Streams.cs b/CliFx/Utils/Polyfills.Streams.cs deleted file mode 100644 index 69ad260..0000000 --- a/CliFx/Utils/Polyfills.Streams.cs +++ /dev/null @@ -1,11 +0,0 @@ -// ReSharper disable CheckNamespace - -#if NETSTANDARD2_0 -using System.IO; - -internal static class StreamPolyfills -{ - public static void Write(this Stream stream, byte[] buffer) => - stream.Write(buffer, 0, buffer.Length); -} -#endif \ No newline at end of file diff --git a/CliFx/Utils/Polyfills.Strings.cs b/CliFx/Utils/Polyfills.Strings.cs deleted file mode 100644 index 5ba6b98..0000000 --- a/CliFx/Utils/Polyfills.Strings.cs +++ /dev/null @@ -1,12 +0,0 @@ -// ReSharper disable CheckNamespace - -#if NETSTANDARD2_0 -internal static class StringPolyfills -{ - public static bool StartsWith(this string str, char c) => - str.Length > 0 && str[0] == c; - - public static bool EndsWith(this string str, char c) => - str.Length > 0 && str[^1] == c; -} -#endif \ No newline at end of file